"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
chunker,compress,crypt,hasher,union: fix rclone move a file over itself deleting the file
Nick Craig-Woodc69eb84573c8
diff --git a/backend/chunker/chunker.go b/backend/chunker/chunker.goindex bb4b49812..baf4656ed 100644--- a/backend/chunker/chunker.go+++ b/backend/chunker/chunker.go@@ -325,6 +325,14 @@ func NewFs(ctx context.Context, name, rpath string, m configmap.Mapper) (fs.Fs,}}+ // Correct root if definitely pointing to a file+ if err == fs.ErrorIsFile {+ f.root = path.Dir(f.root)+ if f.root == "." || f.root == "/" {+ f.root = ""+ }+ }+// Note 1: the features here are ones we could support, and they are// ANDed with the ones from wrappedFs.// Note 2: features.Fill() points features.PutStream to our PutStream,diff --git a/backend/compress/compress.go b/backend/compress/compress.goindex f635c5e59..b477512e7 100644--- a/backend/compress/compress.go+++ b/backend/compress/compress.go@@ -14,6 +14,7 @@ import ("fmt""io""os"+ "path""regexp""strings""time"@@ -172,6 +173,13 @@ func NewFs(ctx context.Context, name, rpath string, m configmap.Mapper) (fs.Fs,opt: *opt,mode: compressionModeFromName(opt.CompressionMode),}+ // Correct root if definitely pointing to a file+ if err == fs.ErrorIsFile {+ f.root = path.Dir(f.root)+ if f.root == "." || f.root == "/" {+ f.root = ""+ }+ }// the features here are ones we could support, and they are// ANDed with the ones from wrappedFsf.features = (&fs.Features{diff --git a/backend/crypt/crypt.go b/backend/crypt/crypt.goindex 281805fd5..54b1335dc 100644--- a/backend/crypt/crypt.go+++ b/backend/crypt/crypt.go@@ -253,6 +253,13 @@ func NewFs(ctx context.Context, name, rpath string, m configmap.Mapper) (fs.Fs,cipher: cipher,}cache.PinUntilFinalized(f.Fs, f)+ // Correct root if definitely pointing to a file+ if err == fs.ErrorIsFile {+ f.root = path.Dir(f.root)+ if f.root == "." || f.root == "/" {+ f.root = ""+ }+ }// the features here are ones we could support, and they are// ANDed with the ones from wrappedFsf.features = (&fs.Features{diff --git a/backend/hasher/hasher.go b/backend/hasher/hasher.goindex 3428b4dc2..325f7f619 100644--- a/backend/hasher/hasher.go+++ b/backend/hasher/hasher.go@@ -114,6 +114,13 @@ func NewFs(ctx context.Context, fsname, rpath string, cmap configmap.Mapper) (fsroot: rpath,opt: opt,}+ // Correct root if definitely pointing to a file+ if err == fs.ErrorIsFile {+ f.root = path.Dir(f.root)+ if f.root == "." || f.root == "/" {+ f.root = ""+ }+ }baseFeatures := baseFs.Features()f.fpTime = baseFs.Precision() != fs.ModTimeNotSupporteddiff --git a/backend/union/union.go b/backend/union/union.goindex eeaed8f31..5854afc11 100644--- a/backend/union/union.go+++ b/backend/union/union.go@@ -877,6 +877,13 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, eopt: *opt,upstreams: usedUpstreams,}+ // Correct root if definitely pointing to a file+ if fserr == fs.ErrorIsFile {+ f.root = path.Dir(f.root)+ if f.root == "." || f.root == "/" {+ f.root = ""+ }+ }err = upstream.Prepare(f.upstreams)if err != nil {return nil, errdiff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.goindex 7ab03dd60..095a94d23 100644--- a/fstest/fstests/fstests.go+++ b/fstest/fstests/fstests.go@@ -1675,6 +1675,24 @@ func Run(t *testing.T, opt *Opt) {require.NotNil(t, fileRemote)assert.Equal(t, fs.ErrorIsFile, err)+ // Check Fs.Root returns the right thing+ t.Run("FsRoot", func(t *testing.T) {+ skipIfNotOk(t)+ got := fileRemote.Root()+ remoteDir := path.Dir(remoteName)+ want := remoteDir+ colon := strings.LastIndex(want, ":")+ if colon >= 0 {+ want = want[colon+1:]+ }+ if isLocalRemote {+ // only check last path element on local+ require.Equal(t, filepath.Base(remoteDir), filepath.Base(got))+ } else {+ require.Equal(t, want, got)+ }+ })+if strings.HasPrefix(remoteName, "TestChunker") && strings.Contains(remoteName, "Nometa") {// TODO fix chunker and remove this bypasst.Logf("Skip listing check -- chunker can't yet handle this tricky case")