local: add --skip-links to suppress symlink warnings

Give users a way to explicitly acknowledge that symlinks are to be skipped
without warnings.

Fixes #1480.
This commit is contained in:
Zhiming Wang 2017-07-21 06:15:58 -04:00 committed by Nick Craig-Wood
parent 6ae29df4d7
commit 6152bab28d
2 changed files with 9 additions and 1 deletions

View file

@ -172,3 +172,8 @@ filesystem.
**NB** This flag is only available on Unix based systems. On systems
where it isn't supported (eg Windows) it will not appear as an valid
flag.
#### --skip-links ####
This flag disables warning messages on skipped symlinks or junction
points, as you explicitly acknowledge that they should be skipped.

View file

@ -23,6 +23,7 @@ import (
var (
followSymlinks = fs.BoolP("copy-links", "L", false, "Follow symlinks and copy the pointed to item.")
skipSymlinks = fs.BoolP("skip-links", "", false, "Don't warn about skipped symlinks.")
noUTFNorm = fs.BoolP("local-no-unicode-normalization", "", false, "Don't apply unicode normalization to paths and filenames")
)
@ -606,7 +607,9 @@ func (o *Object) Storable() bool {
mode &^= os.ModeSymlink
}
if mode&os.ModeSymlink != 0 {
fs.Logf(o, "Can't follow symlink without -L/--copy-links")
if !*skipSymlinks {
fs.Logf(o, "Can't follow symlink without -L/--copy-links")
}
return false
} else if mode&(os.ModeNamedPipe|os.ModeSocket|os.ModeDevice) != 0 {
fs.Logf(o, "Can't transfer non file/directory")