mirror of
https://github.com/octoleo/syncthing.git
synced 2025-02-08 14:58:26 +00:00
This commit is contained in:
parent
91c3218a0c
commit
03d0f0dc34
@ -11,6 +11,7 @@ package fs
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -73,3 +74,5 @@ func (f *BasicFilesystem) unrootedChecked(absPath, root string) string {
|
|||||||
func rel(path, prefix string) string {
|
func rel(path, prefix string) string {
|
||||||
return strings.TrimPrefix(strings.TrimPrefix(path, prefix), string(PathSeparator))
|
return strings.TrimPrefix(strings.TrimPrefix(path, prefix), string(PathSeparator))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var evalSymlinks = filepath.EvalSymlinks
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"github.com/syncthing/notify"
|
"github.com/syncthing/notify"
|
||||||
)
|
)
|
||||||
@ -23,13 +22,10 @@ import (
|
|||||||
var backendBuffer = 500
|
var backendBuffer = 500
|
||||||
|
|
||||||
func (f *BasicFilesystem) Watch(name string, ignore Matcher, ctx context.Context, ignorePerms bool) (<-chan Event, error) {
|
func (f *BasicFilesystem) Watch(name string, ignore Matcher, ctx context.Context, ignorePerms bool) (<-chan Event, error) {
|
||||||
evalRoot, err := filepath.EvalSymlinks(f.root)
|
evalRoot, err := evalSymlinks(f.root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
evalRoot = longFilenameSupport(evalRoot)
|
|
||||||
}
|
|
||||||
|
|
||||||
absName, err := rooted(name, evalRoot)
|
absName, err := rooted(name, evalRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -34,7 +34,7 @@ func TestMain(m *testing.M) {
|
|||||||
panic("Cannot get absolute path to working dir")
|
panic("Cannot get absolute path to working dir")
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, err = filepath.EvalSymlinks(dir)
|
dir, err = evalSymlinks(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Cannot get real path to working dir")
|
panic("Cannot get real path to working dir")
|
||||||
}
|
}
|
||||||
|
@ -210,3 +210,15 @@ func isMaybeWin83(absPath string) bool {
|
|||||||
}
|
}
|
||||||
return strings.Contains(strings.TrimPrefix(filepath.Base(absPath), WindowsTempPrefix), "~")
|
return strings.Contains(strings.TrimPrefix(filepath.Base(absPath), WindowsTempPrefix), "~")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func evalSymlinks(in string) (string, error) {
|
||||||
|
out, err := filepath.EvalSymlinks(in)
|
||||||
|
if err != nil && strings.HasPrefix(in, `\\?\`) {
|
||||||
|
// Try again without the `\\?\` prefix
|
||||||
|
out, err = filepath.EvalSymlinks(in[4:])
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return longFilenameSupport(out), nil
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user