From ca823bd591907ea6eb6625b3a0c54825c79ed7c8 Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Tue, 9 Apr 2019 09:02:04 +0200 Subject: [PATCH] lib/fs: When watching remove \\?\ for drive letters (fixes #5578) (#5633) --- lib/fs/basicfs_watch.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/fs/basicfs_watch.go b/lib/fs/basicfs_watch.go index f00e82060..dbc1ad488 100644 --- a/lib/fs/basicfs_watch.go +++ b/lib/fs/basicfs_watch.go @@ -12,6 +12,7 @@ import ( "context" "errors" "path/filepath" + "runtime" "github.com/syncthing/notify" ) @@ -32,6 +33,12 @@ func (f *BasicFilesystem) Watch(name string, ignore Matcher, ctx context.Context return nil, 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" && len(absName) <= 7 && len(absName) > 4 && absName[:4] == `\\?\` { + absName = absName[4:] + } + outChan := make(chan Event) backendChan := make(chan notify.EventInfo, backendBuffer)