"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
Fix --delete-before deleting files on copy - fixes #1166
Nick Craig-Wood6b0f2ef4bdf9
diff --git a/fs/sync.go b/fs/sync.goindex fd564c4c4..0e0fd596b 100644--- a/fs/sync.go+++ b/fs/sync.go@@ -1052,7 +1052,7 @@ func runSyncCopyMove(fdst, fsrc Fs, deleteMode DeleteMode, DoMove bool) error {return errors.New("can't delete and move at the same time")}// Run an extra pass to delete only- if !*oldSyncMethod && Config.DeleteMode == DeleteModeBefore {+ if !*oldSyncMethod && deleteMode == DeleteModeBefore {if Config.TrackRenames {return errors.New("can't use --delete-before with --track-renames")}diff --git a/fs/sync_test.go b/fs/sync_test.goindex 1c9abb98f..1764c9556 100644--- a/fs/sync_test.go+++ b/fs/sync_test.go@@ -531,6 +531,29 @@ func TestSyncDeleteBefore(t *testing.T) {TestSyncAfterRemovingAFileAndAddingAFile(t)}+// Copy test delete before - shouldn't delete anything+func TestCopyDeleteBefore(t *testing.T) {+ r := NewRun(t)+ defer r.Finalise()++ fs.Config.DeleteMode = fs.DeleteModeBefore+ defer func() {+ fs.Config.DeleteMode = fs.DeleteModeDefault+ }()++ file1 := r.WriteObject("potato", "hopefully not deleted", t1)+ file2 := r.WriteFile("potato2", "hopefully copied in", t1)+ fstest.CheckItems(t, r.fremote, file1)+ fstest.CheckItems(t, r.flocal, file2)++ fs.Stats.ResetCounters()+ err := fs.CopyDir(r.fremote, r.flocal)+ require.NoError(t, err)++ fstest.CheckItems(t, r.fremote, file1, file2)+ fstest.CheckItems(t, r.flocal, file2)+}+// Test with excludefunc TestSyncWithExclude(t *testing.T) {r := NewRun(t)