@@ -773,24 +773,22 @@ func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string, isDu
773
773
var parentLbl trap.Label
774
774
775
775
for i , component := range components {
776
- isRoot := false
776
+ var rawPath , canonicalPath string
777
777
if i == 0 {
778
- if component == "" {
779
- path = "/"
780
- isRoot = true
781
- } else if regexp .MustCompile (`^[A-Za-z]:$` ).MatchString (component ) {
782
- // Handle Windows drive letters by appending "/"
783
- path = component + "/"
784
- isRoot = true
778
+ rawPath = component
779
+ if component == "" || regexp .MustCompile (`^[A-Za-z]:$` ).MatchString (component ) {
780
+ // Handle linux root and Windows drive letters by appending "/"
781
+ canonicalPath = rawPath + "/"
785
782
} else {
786
- path = component
783
+ canonicalPath = rawPath
787
784
}
788
785
} else {
789
- path = parentPath + "/" + component
786
+ rawPath = parentPath + "/" + component
787
+ canonicalPath = rawPath
790
788
}
791
789
if i == len (components )- 1 {
792
790
lbl := tw .Labeler .FileLabelFor (file )
793
- dbscheme .FilesTable .Emit (tw , lbl , path )
791
+ dbscheme .FilesTable .Emit (tw , lbl , canonicalPath )
794
792
dbscheme .ContainerParentTable .Emit (tw , parentLbl , lbl )
795
793
dbscheme .HasLocationTable .Emit (tw , lbl , emitLocation (tw , lbl , 0 , 0 , 0 , 0 ))
796
794
extraction .Lock .Lock ()
@@ -801,14 +799,12 @@ func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string, isDu
801
799
extraction .Lock .Unlock ()
802
800
break
803
801
}
804
- lbl := tw .Labeler .GlobalID (util .EscapeTrapSpecialChars (path ) + ";folder" )
805
- dbscheme .FoldersTable .Emit (tw , lbl , path )
802
+ lbl := tw .Labeler .GlobalID (util .EscapeTrapSpecialChars (canonicalPath ) + ";folder" )
803
+ dbscheme .FoldersTable .Emit (tw , lbl , canonicalPath )
806
804
if i > 0 {
807
805
dbscheme .ContainerParentTable .Emit (tw , parentLbl , lbl )
808
806
}
809
- if ! isRoot {
810
- parentPath = path
811
- }
807
+ parentPath = rawPath
812
808
parentLbl = lbl
813
809
}
814
810
}
0 commit comments