lib/fs: Case insensitive conversion to rel path on windows (fixes #5183) (#5176)

This commit is contained in:
Simon Frei
2018-09-11 22:30:32 +02:00
committed by Jakob Borg
parent 60a6a40175
commit 50ba0fd079
7 changed files with 121 additions and 26 deletions

View File

@@ -11,10 +11,8 @@ package fs
import (
"context"
"errors"
"fmt"
"path/filepath"
"runtime"
"strings"
"github.com/syncthing/notify"
)
@@ -114,18 +112,3 @@ func (f *BasicFilesystem) eventType(notifyType notify.Event) EventType {
}
return NonRemove
}
// unrootedChecked returns the path relative to the folder root (same as
// unrooted). It panics if the given path is not a subpath and handles the
// special case when the given path is the folder root without a trailing
// pathseparator.
func (f *BasicFilesystem) unrootedChecked(absPath, root string) string {
absPath = f.resolveWin83(absPath)
if absPath+string(PathSeparator) == root {
return "."
}
if !strings.HasPrefix(absPath, root) {
panic(fmt.Sprintf("bug: Notify backend is processing a change outside of the filesystem root: f.root==%v, root==%v, path==%v", f.root, root, absPath))
}
return rel(absPath, root)
}