"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
local: fix directories named *.rclonelink being treated as links with --links
Nick Craig-Wooda7ef4c90648a
diff --git a/backend/local/local.go b/backend/local/local.goindex 7db5e2c4c..73aea3bbb 100644--- a/backend/local/local.go+++ b/backend/local/local.go@@ -644,15 +644,23 @@ func (f *Fs) NewObject(ctx context.Context, remote string) (fs.Object, error) {}// Create new directory object from the info passed in+//+// Directories are never translated links, so the name is used as is+// whatever suffix it has.func (f *Fs) newDirectory(dir string, fi os.FileInfo) (*Directory, error) {- o, err := f.newObject(dir)+ localPath, err := f.localPath(dir)if err != nil {return nil, err}- o.setMetadata(fi)- return &Directory{- Object: *o,- }, nil+ d := &Directory{+ Object: Object{+ fs: f,+ remote: dir,+ path: localPath,+ },+ }+ d.setMetadata(fi)+ return d, nil}// List the objects and directories in dir into entries. Thediff --git a/backend/local/local_internal_test.go b/backend/local/local_internal_test.goindex ab5a2f6db..b8525ad90 100644--- a/backend/local/local_internal_test.go+++ b/backend/local/local_internal_test.go@@ -646,6 +646,38 @@ func TestLocalPath(t *testing.T) {}}+// TestLinkSuffixDirectory checks that in --links mode a directory whose+// name ends in ".rclonelink" is an ordinary directory. Only files are+// translated into links, so the suffix must stay in its path rather+// than making it address a sibling.+func TestLinkSuffixDirectory(t *testing.T) {+ ctx := context.Background()+ r := fstest.NewRun(t)+ f := r.Flocal.(*Fs)+ linksMode(f)++ dir := "sub" + fs.LinkSuffix+ want := filepath.Join(f.root, dir)+ mtime := fstest.Time("2001-02-03T04:05:06Z")++ d, err := f.MkdirMetadata(ctx, dir, fs.Metadata{"mtime": mtime.Format(time.RFC3339Nano)})+ require.NoError(t, err)+ assert.Equal(t, want, d.(*Directory).path)+ fi, err := os.Lstat(want)+ require.NoError(t, err)+ assert.True(t, fi.IsDir())+ assert.True(t, fi.ModTime().Equal(mtime), "metadata was not written to the directory")++ entries, err := f.List(ctx, "")+ require.NoError(t, err)+ require.Len(t, entries, 1)+ got, ok := entries[0].(*Directory)+ require.True(t, ok)+ assert.Equal(t, dir, got.Remote())+ assert.Equal(t, want, got.path)+ assert.False(t, got.translatedLink)+}+func TestHashWithTypeNone(t *testing.T) {ctx := context.Background()r := fstest.NewRun(t)