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

@@ -295,21 +295,16 @@ func (d *SourceFilesystem) Contains(filename string) bool {
return false
}
// Path returns the relative path to the given filename if it is a member of
// Path returns the mount relative path to the given filename if it is a member of
// of the current filesystem, an empty string if not.
func (d *SourceFilesystem) Path(filename string) string {
for _, dir := range d.Dirs {
meta := dir.Meta()
if !dir.IsDir() {
if filename == meta.Filename() {
return meta.PathFile()
}
continue
}
if strings.HasPrefix(filename, meta.Filename()) {
p := strings.TrimPrefix(strings.TrimPrefix(filename, meta.Filename()), filePathSeparator)
p = path.Join(meta.PathFile(), p)
if mountRoot := meta.MountRoot(); mountRoot != "" {
return filepath.Join(mountRoot, p)
}
return p
}
}