1
mirror of https://github.com/rclone/rclone synced 2024-11-29 07:55:12 +01:00

local: make using -l/--links with -L/--copy-links throw an error #1152

This commit is contained in:
Nick Craig-Wood 2019-01-27 19:28:57 +00:00
parent 65ff330602
commit e317f04098
3 changed files with 23 additions and 4 deletions

View File

@ -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 // NewFs constructs an Fs from the path
func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) { func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) {
// Parse config into Options struct // Parse config into Options struct
@ -150,6 +152,9 @@ func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if opt.TranslateSymlinks && opt.FollowSymlinks {
return nil, errLinksAndCopyLinks
}
if opt.NoUTFNorm { if opt.NoUTFNorm {
fs.Errorf(nil, "The --local-no-unicode-normalization flag is deprecated and will be removed") fs.Errorf(nil, "The --local-no-unicode-normalization flag is deprecated and will be removed")

View File

@ -9,6 +9,7 @@ import (
"time" "time"
"github.com/ncw/rclone/fs" "github.com/ncw/rclone/fs"
"github.com/ncw/rclone/fs/config/configmap"
"github.com/ncw/rclone/fs/hash" "github.com/ncw/rclone/fs/hash"
"github.com/ncw/rclone/fstest" "github.com/ncw/rclone/fstest"
"github.com/ncw/rclone/lib/file" "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.Equal(t, "file.txt"[2:5+1], string(contents))
require.NoError(t, in.Close()) 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)
}

View File

@ -81,7 +81,8 @@ Normally rclone will ignore symlinks or junction points (which behave
like symlinks under Windows). like symlinks under Windows).
If you supply `--copy-links` or `-L` then rclone will follow the 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. 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 Normally rclone will ignore symlinks or junction points (which behave
like symlinks under Windows). 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. 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. This flag applies to all commands.
@ -151,7 +152,7 @@ $ rclone ls remote:/tmp/a
14 file2.rclonelink 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 $ rclone cat remote:/tmp/a/file1.rclonelink
@ -183,7 +184,10 @@ $ tree /tmp/b
└── file2.rclonelink └── file2.rclonelink
```` ````
Note that this flag is incompatible with `-copy-links` / `-L`.
### Restricting filesystems with --one-file-system ### Restricting filesystems with --one-file-system
Normally rclone will recurse through filesystems as mounted. Normally rclone will recurse through filesystems as mounted.
However if you set `--one-file-system` or `-x` this tells rclone to However if you set `--one-file-system` or `-x` this tells rclone to