mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
fix previous commit
This commit is contained in:
@@ -773,24 +773,22 @@ func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string, isDu
|
|||||||
var parentLbl trap.Label
|
var parentLbl trap.Label
|
||||||
|
|
||||||
for i, component := range components {
|
for i, component := range components {
|
||||||
isRoot := false
|
var rawPath, canonicalPath string
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
if component == "" {
|
rawPath = component
|
||||||
path = "/"
|
if component == "" || regexp.MustCompile(`^[A-Za-z]:$`).MatchString(component) {
|
||||||
isRoot = true
|
// Handle linux root and Windows drive letters by appending "/"
|
||||||
} else if regexp.MustCompile(`^[A-Za-z]:$`).MatchString(component) {
|
canonicalPath = rawPath + "/"
|
||||||
// Handle Windows drive letters by appending "/"
|
|
||||||
path = component + "/"
|
|
||||||
isRoot = true
|
|
||||||
} else {
|
} else {
|
||||||
path = component
|
canonicalPath = rawPath
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
path = parentPath + "/" + component
|
rawPath = parentPath + "/" + component
|
||||||
|
canonicalPath = rawPath
|
||||||
}
|
}
|
||||||
if i == len(components)-1 {
|
if i == len(components)-1 {
|
||||||
lbl := tw.Labeler.FileLabelFor(file)
|
lbl := tw.Labeler.FileLabelFor(file)
|
||||||
dbscheme.FilesTable.Emit(tw, lbl, path)
|
dbscheme.FilesTable.Emit(tw, lbl, canonicalPath)
|
||||||
dbscheme.ContainerParentTable.Emit(tw, parentLbl, lbl)
|
dbscheme.ContainerParentTable.Emit(tw, parentLbl, lbl)
|
||||||
dbscheme.HasLocationTable.Emit(tw, lbl, emitLocation(tw, lbl, 0, 0, 0, 0))
|
dbscheme.HasLocationTable.Emit(tw, lbl, emitLocation(tw, lbl, 0, 0, 0, 0))
|
||||||
extraction.Lock.Lock()
|
extraction.Lock.Lock()
|
||||||
@@ -801,14 +799,12 @@ func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string, isDu
|
|||||||
extraction.Lock.Unlock()
|
extraction.Lock.Unlock()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
lbl := tw.Labeler.GlobalID(util.EscapeTrapSpecialChars(path) + ";folder")
|
lbl := tw.Labeler.GlobalID(util.EscapeTrapSpecialChars(canonicalPath) + ";folder")
|
||||||
dbscheme.FoldersTable.Emit(tw, lbl, path)
|
dbscheme.FoldersTable.Emit(tw, lbl, canonicalPath)
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
dbscheme.ContainerParentTable.Emit(tw, parentLbl, lbl)
|
dbscheme.ContainerParentTable.Emit(tw, parentLbl, lbl)
|
||||||
}
|
}
|
||||||
if !isRoot {
|
parentPath = rawPath
|
||||||
parentPath = path
|
|
||||||
}
|
|
||||||
parentLbl = lbl
|
parentLbl = lbl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user