@@ -773,24 +773,22 @@ func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string, isDu
773773 var parentLbl trap.Label
774774
775775 for i , component := range components {
776- isRoot := false
776+ var rawPath , canonicalPath string
777777 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 + "/"
785782 } else {
786- path = component
783+ canonicalPath = rawPath
787784 }
788785 } else {
789- path = parentPath + "/" + component
786+ rawPath = parentPath + "/" + component
787+ canonicalPath = rawPath
790788 }
791789 if i == len (components )- 1 {
792790 lbl := tw .Labeler .FileLabelFor (file )
793- dbscheme .FilesTable .Emit (tw , lbl , path )
791+ dbscheme .FilesTable .Emit (tw , lbl , canonicalPath )
794792 dbscheme .ContainerParentTable .Emit (tw , parentLbl , lbl )
795793 dbscheme .HasLocationTable .Emit (tw , lbl , emitLocation (tw , lbl , 0 , 0 , 0 , 0 ))
796794 extraction .Lock .Lock ()
@@ -801,14 +799,12 @@ func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string, isDu
801799 extraction .Lock .Unlock ()
802800 break
803801 }
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 )
806804 if i > 0 {
807805 dbscheme .ContainerParentTable .Emit (tw , parentLbl , lbl )
808806 }
809- if ! isRoot {
810- parentPath = path
811- }
807+ parentPath = rawPath
812808 parentLbl = lbl
813809 }
814810}
0 commit comments