lib/fs: Consider win83 for root path as well when watching (ref #5706) (#5709)

This commit is contained in:
Simon Frei
2019-05-11 10:06:04 +02:00
committed by Jakob Borg
parent fbd445fe0a
commit dfbbb286fc
4 changed files with 49 additions and 24 deletions

View File

@@ -11,8 +11,6 @@ package fs
import (
"context"
"errors"
"path/filepath"
"runtime"
"github.com/syncthing/notify"
)
@@ -57,28 +55,6 @@ func (f *BasicFilesystem) Watch(name string, ignore Matcher, ctx context.Context
return outChan, nil
}
// watchPaths adjust the folder root for use with the notify backend and the
// corresponding absolute path to be passed to notify to watch name.
func (f *BasicFilesystem) watchPaths(name string) (string, string, error) {
root, err := evalSymlinks(f.root)
if err != nil {
return "", "", err
}
// Remove `\\?\` prefix if the path is just a drive letter as a dirty
// fix for https://github.com/syncthing/syncthing/issues/5578
if runtime.GOOS == "windows" && filepath.Clean(name) == "." && len(root) <= 7 && len(root) > 4 && root[:4] == `\\?\` {
root = root[4:]
}
absName, err := rooted(name, root)
if err != nil {
return "", "", err
}
return filepath.Join(absName, "..."), root, nil
}
func (f *BasicFilesystem) watchLoop(name, evalRoot string, backendChan chan notify.EventInfo, outChan chan<- Event, ignore Matcher, ctx context.Context) {
for {
// Detect channel overflow