From 17b25d7ce2426c93aff54ef251b8087fa0d35140 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 22 May 2025 16:58:06 +0100 Subject: [PATCH] local: fix --skip-links on Windows when skipping Junction points Due to a change in Go which was enabled by the `go 1.22` in `go.mod` rclone has stopped skipping junction points ("My Documents" in particular) if `--skip-links` is set on Windows. This is because the output from os.Lstat has changed and junction points are no longer marked with os.ModeSymlink but with os.ModeIrregular instead. This fix now skips os.ModeIrregular objects if --skip-links is set on Windows only. Fixes #8561 See: https://github.com/golang/go/issues/73827 --- backend/local/local.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/local/local.go b/backend/local/local.go index 3a4f0b2de..39e420e0e 100644 --- a/backend/local/local.go +++ b/backend/local/local.go @@ -1201,7 +1201,15 @@ func (o *Object) Storable() bool { o.fs.objectMetaMu.RLock() mode := o.mode o.fs.objectMetaMu.RUnlock() - if mode&os.ModeSymlink != 0 && !o.fs.opt.TranslateSymlinks { + + // On Windows items with os.ModeIrregular are likely Junction + // points so we treat them as symlinks for the purpose of ignoring them. + // https://github.com/golang/go/issues/73827 + symlinkFlag := os.ModeSymlink + if runtime.GOOS == "windows" { + symlinkFlag |= os.ModeIrregular + } + if mode&symlinkFlag != 0 && !o.fs.opt.TranslateSymlinks { if !o.fs.opt.SkipSymlinks { fs.Logf(o, "Can't follow symlink without -L/--copy-links") }