Fix 0.62.1 server rebuild slowdown regression

Fixes #6784
This commit is contained in:
Bjørn Erik Pedersen
2020-01-22 11:57:23 +01:00
parent 2fefc01606
commit 17af79a03e
10 changed files with 186 additions and 36 deletions

View File

@@ -34,9 +34,9 @@ import (
)
const (
metaKeyFilename = "filename"
metaKeyPathFile = "pathFile" // Path of filename relative to a root.
metaKeyIsFileMount = "isFileMount" // Whether the source mount was a file.
metaKeyFilename = "filename"
metaKeyBaseDir = "baseDir" // Abs base directory of source file.
metaKeyMountRoot = "mountRoot"
metaKeyOriginalFilename = "originalFilename"
metaKeyName = "name"
@@ -116,29 +116,19 @@ func (f FileMeta) Path() string {
return f.stringV(metaKeyPath)
}
// PathFile returns the relative file path for the file source. This
// will in most cases be the same as Path.
// PathFile returns the relative file path for the file source.
func (f FileMeta) PathFile() string {
pf := f.stringV(metaKeyPathFile)
if f.isFileMount() {
return pf
base := f.stringV(metaKeyBaseDir)
if base == "" {
return ""
}
mountRoot := f.mountRoot()
if mountRoot == pf {
return f.Path()
}
return pf + (strings.TrimPrefix(f.Path(), mountRoot))
return strings.TrimPrefix(strings.TrimPrefix(f.Filename(), base), filepathSeparator)
}
func (f FileMeta) mountRoot() string {
func (f FileMeta) MountRoot() string {
return f.stringV(metaKeyMountRoot)
}
func (f FileMeta) isFileMount() bool {
return f.GetBool(metaKeyIsFileMount)
}
func (f FileMeta) Weight() int {
return f.GetInt(metaKeyWeight)
}