diff --git a/backend/local/local.go b/backend/local/local.go index a17a0cf53..039d5d86e 100644 --- a/backend/local/local.go +++ b/backend/local/local.go @@ -142,6 +142,8 @@ type Object struct { // ------------------------------------------------------------ +var errLinksAndCopyLinks = errors.New("can't use -l/--links with -L/--copy-links") + // NewFs constructs an Fs from the path func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) { // Parse config into Options struct @@ -150,6 +152,9 @@ func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) { if err != nil { return nil, err } + if opt.TranslateSymlinks && opt.FollowSymlinks { + return nil, errLinksAndCopyLinks + } if opt.NoUTFNorm { fs.Errorf(nil, "The --local-no-unicode-normalization flag is deprecated and will be removed") diff --git a/backend/local/local_internal_test.go b/backend/local/local_internal_test.go index 54d9dc1fe..46493f1ee 100644 --- a/backend/local/local_internal_test.go +++ b/backend/local/local_internal_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/ncw/rclone/fs" + "github.com/ncw/rclone/fs/config/configmap" "github.com/ncw/rclone/fs/hash" "github.com/ncw/rclone/fstest" "github.com/ncw/rclone/lib/file" @@ -164,3 +165,12 @@ func TestSymlink(t *testing.T) { require.Equal(t, "file.txt"[2:5+1], string(contents)) require.NoError(t, in.Close()) } + +func TestSymlinkError(t *testing.T) { + m := configmap.Simple{ + "links": "true", + "copy_links": "true", + } + _, err := NewFs("local", "/", m) + assert.Equal(t, errLinksAndCopyLinks, err) +} diff --git a/docs/content/local.md b/docs/content/local.md index 03987d138..be5e26e20 100644 --- a/docs/content/local.md +++ b/docs/content/local.md @@ -81,7 +81,8 @@ Normally rclone will ignore symlinks or junction points (which behave like symlinks under Windows). If you supply `--copy-links` or `-L` then rclone will follow the -symlink and copy the pointed to file or directory. +symlink and copy the pointed to file or directory. Note that this +flag is incompatible with `-links` / `-l`. This flag applies to all commands. @@ -121,10 +122,10 @@ $ rclone -L ls /tmp/a Normally rclone will ignore symlinks or junction points (which behave like symlinks under Windows). -If you supply this flag then rclone will copy symblic links from the local storage, +If you supply this flag then rclone will copy symbolic links from the local storage, and store them as text files, with a '.rclonelink' suffix in the remote storage. -The text file will contain the target of the symblic link (see example). +The text file will contain the target of the symbolic link (see example). This flag applies to all commands. @@ -151,7 +152,7 @@ $ rclone ls remote:/tmp/a 14 file2.rclonelink ``` -The remote files will contain the target of the symblic links +The remote files will contain the target of the symbolic links ``` $ rclone cat remote:/tmp/a/file1.rclonelink @@ -183,7 +184,10 @@ $ tree /tmp/b └── file2.rclonelink ```` +Note that this flag is incompatible with `-copy-links` / `-L`. + ### Restricting filesystems with --one-file-system + Normally rclone will recurse through filesystems as mounted. However if you set `--one-file-system` or `-x` this tells rclone to