Skip to content

Commit a92af34

Browse files
authored
local: fix --copy-links on Windows when listing Junction points
1 parent 8ffde40 commit a92af34

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

backend/local/local.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,12 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e
671671
name := fi.Name()
672672
mode := fi.Mode()
673673
newRemote := f.cleanRemote(dir, name)
674+
symlinkFlag := os.ModeSymlink
675+
if runtime.GOOS == "windows" {
676+
symlinkFlag |= os.ModeIrregular
677+
}
674678
// Follow symlinks if required
675-
if f.opt.FollowSymlinks && (mode&os.ModeSymlink) != 0 {
679+
if f.opt.FollowSymlinks && (mode&symlinkFlag) != 0 {
676680
localPath := filepath.Join(fsDirPath, name)
677681
fi, err = os.Stat(localPath)
678682
// Quietly skip errors on excluded files and directories
@@ -694,13 +698,13 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e
694698
if fi.IsDir() {
695699
// Ignore directories which are symlinks. These are junction points under windows which
696700
// are kind of a souped up symlink. Unix doesn't have directories which are symlinks.
697-
if (mode&os.ModeSymlink) == 0 && f.dev == readDevice(fi, f.opt.OneFileSystem) {
701+
if (mode&symlinkFlag) == 0 && f.dev == readDevice(fi, f.opt.OneFileSystem) {
698702
d := f.newDirectory(newRemote, fi)
699703
entries = append(entries, d)
700704
}
701705
} else {
702706
// Check whether this link should be translated
703-
if f.opt.TranslateSymlinks && fi.Mode()&os.ModeSymlink != 0 {
707+
if f.opt.TranslateSymlinks && fi.Mode()&symlinkFlag != 0 {
704708
newRemote += fs.LinkSuffix
705709
}
706710
// Don't include non directory if not included

0 commit comments

Comments
 (0)