Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

bisync: fix internal error when a conflict rename reuses deleted names - fixes #10165

TastyHeadphones1d11d9492730
diff --git a/cmd/bisync/listing.go b/cmd/bisync/listing.go
index 99f7fe62f..2cf92d61a 100644
--- a/cmd/bisync/listing.go
+++ b/cmd/bisync/listing.go
@@ -581,6 +581,11 @@ func (b *bisyncRun) modifyListing(ctx context.Context, src fs.Fs, dst fs.Fs, res
// account for "deltaOthers" we handled separately
if queues.deletedonboth.NotEmpty() {
for file := range queues.deletedonboth {
+ // a conflict rename can reuse the name of a file deleted on
+ // both sides, in which case it was just copied and must stay
+ if queues.copy1to2.Has(file) || queues.copy2to1.Has(file) {
+ continue
+ }
srcList.remove(file)
dstList.remove(file)
}
diff --git a/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.copy1to2.que b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.copy1to2.que
new file mode 100644
index 000000000..91974e009
--- /dev/null
+++ b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.copy1to2.que
@@ -0,0 +1 @@
+"file1.txt.conflict1"
diff --git a/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.copy2to1.que b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.copy2to1.que
new file mode 100644
index 000000000..172a192aa
--- /dev/null
+++ b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.copy2to1.que
@@ -0,0 +1 @@
+"file1.txt.conflict2"
diff --git a/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path1.lst b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path1.lst
new file mode 100644
index 000000000..a30157879
--- /dev/null
+++ b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path1.lst
@@ -0,0 +1,8 @@
+# bisync listing v1 from test
+- 109 - - 2000-01-01T00:00:00.000000000+0000 "RCLONE_TEST"
+- 33 - - 2002-03-04T00:00:00.000000000+0000 "file1.txt.conflict1"
+- 33 - - 2002-01-02T00:00:00.000000000+0000 "file1.txt.conflict2"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
diff --git a/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path1.lst-new b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path1.lst-new
new file mode 100644
index 000000000..a30157879
--- /dev/null
+++ b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path1.lst-new
@@ -0,0 +1,8 @@
+# bisync listing v1 from test
+- 109 - - 2000-01-01T00:00:00.000000000+0000 "RCLONE_TEST"
+- 33 - - 2002-03-04T00:00:00.000000000+0000 "file1.txt.conflict1"
+- 33 - - 2002-01-02T00:00:00.000000000+0000 "file1.txt.conflict2"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
diff --git a/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path1.lst-old b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path1.lst-old
new file mode 100644
index 000000000..a30157879
--- /dev/null
+++ b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path1.lst-old
@@ -0,0 +1,8 @@
+# bisync listing v1 from test
+- 109 - - 2000-01-01T00:00:00.000000000+0000 "RCLONE_TEST"
+- 33 - - 2002-03-04T00:00:00.000000000+0000 "file1.txt.conflict1"
+- 33 - - 2002-01-02T00:00:00.000000000+0000 "file1.txt.conflict2"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
diff --git a/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path2.lst b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path2.lst
new file mode 100644
index 000000000..a30157879
--- /dev/null
+++ b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path2.lst
@@ -0,0 +1,8 @@
+# bisync listing v1 from test
+- 109 - - 2000-01-01T00:00:00.000000000+0000 "RCLONE_TEST"
+- 33 - - 2002-03-04T00:00:00.000000000+0000 "file1.txt.conflict1"
+- 33 - - 2002-01-02T00:00:00.000000000+0000 "file1.txt.conflict2"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
diff --git a/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path2.lst-new b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path2.lst-new
new file mode 100644
index 000000000..a30157879
--- /dev/null
+++ b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path2.lst-new
@@ -0,0 +1,8 @@
+# bisync listing v1 from test
+- 109 - - 2000-01-01T00:00:00.000000000+0000 "RCLONE_TEST"
+- 33 - - 2002-03-04T00:00:00.000000000+0000 "file1.txt.conflict1"
+- 33 - - 2002-01-02T00:00:00.000000000+0000 "file1.txt.conflict2"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
diff --git a/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path2.lst-old b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path2.lst-old
new file mode 100644
index 000000000..a30157879
--- /dev/null
+++ b/cmd/bisync/testdata/test_conflict_reuse/golden/_testdir_path1.._testdir_path2.path2.lst-old
@@ -0,0 +1,8 @@
+# bisync listing v1 from test
+- 109 - - 2000-01-01T00:00:00.000000000+0000 "RCLONE_TEST"
+- 33 - - 2002-03-04T00:00:00.000000000+0000 "file1.txt.conflict1"
+- 33 - - 2002-01-02T00:00:00.000000000+0000 "file1.txt.conflict2"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 0 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
diff --git a/cmd/bisync/testdata/test_conflict_reuse/golden/test.log b/cmd/bisync/testdata/test_conflict_reuse/golden/test.log
new file mode 100644
index 000000000..ed87fc5c9
--- /dev/null
+++ b/cmd/bisync/testdata/test_conflict_reuse/golden/test.log
@@ -0,0 +1,143 @@
+(01) : test conflict reuse
+
+
+(02) : test initial bisync
+(03) : bisync resync
+INFO : Setting --ignore-listing-checksum as neither --checksum nor --compare checksum are set.
+INFO : Bisyncing with Comparison Settings:
+{
+"Modtime": true,
+"Size": true,
+"Checksum": false,
+"NoSlowHash": false,
+"SlowHashSyncOnly": false,
+"DownloadHash": false
+}
+INFO : Synching Path1 "{path1/}" with Path2 "{path2/}"
+INFO : Copying Path2 files to Path1
+INFO : - Path2 Resync is copying files to - Path1
+INFO : There was nothing to transfer
+INFO : - Path1 Resync is copying files to - Path2
+INFO : There was nothing to transfer
+INFO : Resync updating listings
+INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}"
+INFO : Bisync successful
+
+(04) : test changed on both paths and NOT identical - file1 (file1R, file1L)
+(05) : touch-glob 2001-01-02 {datadir/} file1R.txt
+(06) : copy-as {datadir/}file1R.txt {path2/} file1.txt
+(07) : touch-glob 2001-03-04 {datadir/} file1L.txt
+(08) : copy-as {datadir/}file1L.txt {path1/} file1.txt
+
+(09) : test bisync run with --conflict-resolve=none --conflict-loser=num
+
+(10) : bisync conflict-resolve=none conflict-loser=num conflict-suffix=conflict
+INFO : Setting --ignore-listing-checksum as neither --checksum nor --compare checksum are set.
+INFO : Bisyncing with Comparison Settings:
+{
+"Modtime": true,
+"Size": true,
+"Checksum": false,
+"NoSlowHash": false,
+"SlowHashSyncOnly": false,
+"DownloadHash": false
+}
+INFO : Synching Path1 "{path1/}" with Path2 "{path2/}"
+INFO : Building Path1 and Path2 listings
+INFO : Path1 checking for diffs
+INFO : - Path1 File changed: size (larger), time (newer) - file1.txt
+INFO : Path1: 1 changes:  0 new,  1 modified,  0 deleted
+INFO : (Modified:  1 newer,  0 older,  1 larger,  0 smaller)
+INFO : Path2 checking for diffs
+INFO : - Path2 File changed: size (larger), time (newer) - file1.txt
+INFO : Path2: 1 changes:  0 new,  1 modified,  0 deleted
+INFO : (Modified:  1 newer,  0 older,  1 larger,  0 smaller)
+INFO : Applying changes
+INFO : Checking potential conflicts...
+ERROR : file1.txt: {hashtype} differ
+NOTICE: {path2String}: 1 differences found
+NOTICE: {path2String}: 1 errors while checking
+INFO : Finished checking the potential conflicts. 1 differences found
+NOTICE: - WARNING New or changed in both paths - file1.txt
+NOTICE: - Path1 Renaming Path1 copy - {path1/}file1.txt.conflict1
+NOTICE: - Path1 Queue copy to Path2 - {path2/}file1.txt.conflict1
+NOTICE: - Path2 Renaming Path2 copy - {path2/}file1.txt.conflict2
+NOTICE: - Path2 Queue copy to Path1 - {path1/}file1.txt.conflict2
+INFO : - Path2 Do queued copies to - Path1
+INFO : - Path1 Do queued copies to - Path2
+INFO : Updating listings
+INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}"
+INFO : Bisync successful
+
+(11) : test restore file1.txt on both paths, NOT identical, and delete the conflict copies
+(12) : delete-file {path1/}file1.txt.conflict1
+(13) : delete-file {path1/}file1.txt.conflict2
+(14) : delete-file {path2/}file1.txt.conflict1
+(15) : delete-file {path2/}file1.txt.conflict2
+(16) : touch-glob 2002-01-02 {datadir/} file1R.txt
+(17) : copy-as {datadir/}file1R.txt {path2/} file1.txt
+(18) : touch-glob 2002-03-04 {datadir/} file1L.txt
+(19) : copy-as {datadir/}file1L.txt {path1/} file1.txt
+
+(20) : test bisync run reuses the deleted conflict names
+
+(21) : bisync conflict-resolve=none conflict-loser=num conflict-suffix=conflict
+INFO : Setting --ignore-listing-checksum as neither --checksum nor --compare checksum are set.
+INFO : Bisyncing with Comparison Settings:
+{
+"Modtime": true,
+"Size": true,
+"Checksum": false,
+"NoSlowHash": false,
+"SlowHashSyncOnly": false,
+"DownloadHash": false
+}
+INFO : Synching Path1 "{path1/}" with Path2 "{path2/}"
+INFO : Building Path1 and Path2 listings
+INFO : Path1 checking for diffs
+INFO : - Path1 File was deleted - file1.txt.conflict1
+INFO : - Path1 File was deleted - file1.txt.conflict2
+INFO : - Path1 File is new - file1.txt
+INFO : Path1: 3 changes:  1 new,  0 modified,  2 deleted
+INFO : Path2 checking for diffs
+INFO : - Path2 File was deleted - file1.txt.conflict1
+INFO : - Path2 File was deleted - file1.txt.conflict2
+INFO : - Path2 File is new - file1.txt
+INFO : Path2: 3 changes:  1 new,  0 modified,  2 deleted
+INFO : Applying changes
+INFO : Checking potential conflicts...
+ERROR : file1.txt: {hashtype} differ
+NOTICE: {path2String}: 1 differences found
+NOTICE: {path2String}: 1 errors while checking
+INFO : Finished checking the potential conflicts. 1 differences found
+NOTICE: - WARNING New or changed in both paths - file1.txt
+NOTICE: - Path1 Renaming Path1 copy - {path1/}file1.txt.conflict1
+NOTICE: - Path1 Queue copy to Path2 - {path2/}file1.txt.conflict1
+NOTICE: - Path2 Renaming Path2 copy - {path2/}file1.txt.conflict2
+NOTICE: - Path2 Queue copy to Path1 - {path1/}file1.txt.conflict2
+INFO : - Path2 Do queued copies to - Path1
+INFO : - Path1 Do queued copies to - Path2
+INFO : Updating listings
+INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}"
+INFO : Bisync successful
+
+(22) : test next bisync run has no changes
+(23) : bisync
+INFO : Setting --ignore-listing-checksum as neither --checksum nor --compare checksum are set.
+INFO : Bisyncing with Comparison Settings:
+{
+"Modtime": true,
+"Size": true,
+"Checksum": false,
+"NoSlowHash": false,
+"SlowHashSyncOnly": false,
+"DownloadHash": false
+}
+INFO : Synching Path1 "{path1/}" with Path2 "{path2/}"
+INFO : Building Path1 and Path2 listings
+INFO : Path1 checking for diffs
+INFO : Path2 checking for diffs
+INFO : No changes found
+INFO : Updating listings
+INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}"
+INFO : Bisync successful
diff --git a/cmd/bisync/testdata/test_conflict_reuse/initial/RCLONE_TEST b/cmd/bisync/testdata/test_conflict_reuse/initial/RCLONE_TEST
new file mode 100644
index 000000000..d8ca97c2a
--- /dev/null
+++ b/cmd/bisync/testdata/test_conflict_reuse/initial/RCLONE_TEST
@@ -0,0 +1 @@
+This file is used for testing the health of rclone accesses to the local/remote file system. Do not delete.
diff --git a/cmd/bisync/testdata/test_conflict_reuse/initial/file1.txt b/cmd/bisync/testdata/test_conflict_reuse/initial/file1.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/cmd/bisync/testdata/test_conflict_reuse/initial/file2.txt b/cmd/bisync/testdata/test_conflict_reuse/initial/file2.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/cmd/bisync/testdata/test_conflict_reuse/initial/file3.txt b/cmd/bisync/testdata/test_conflict_reuse/initial/file3.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/cmd/bisync/testdata/test_conflict_reuse/initial/file4.txt b/cmd/bisync/testdata/test_conflict_reuse/initial/file4.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/cmd/bisync/testdata/test_conflict_reuse/initial/file5.txt b/cmd/bisync/testdata/test_conflict_reuse/initial/file5.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/cmd/bisync/testdata/test_conflict_reuse/modfiles/file1L.txt b/cmd/bisync/testdata/test_conflict_reuse/modfiles/file1L.txt
new file mode 100644
index 000000000..6906ccb09
--- /dev/null
+++ b/cmd/bisync/testdata/test_conflict_reuse/modfiles/file1L.txt
@@ -0,0 +1 @@
+This file is NOT identical to 1R
diff --git a/cmd/bisync/testdata/test_conflict_reuse/modfiles/file1R.txt b/cmd/bisync/testdata/test_conflict_reuse/modfiles/file1R.txt
new file mode 100644
index 000000000..e49d06a94
--- /dev/null
+++ b/cmd/bisync/testdata/test_conflict_reuse/modfiles/file1R.txt
@@ -0,0 +1 @@
+This file is NOT identical to 1L
diff --git a/cmd/bisync/testdata/test_conflict_reuse/scenario.txt b/cmd/bisync/testdata/test_conflict_reuse/scenario.txt
new file mode 100644
index 000000000..5f4dc7247
--- /dev/null
+++ b/cmd/bisync/testdata/test_conflict_reuse/scenario.txt
@@ -0,0 +1,34 @@
+test conflict reuse
+# Recreate a conflicted file under its original name on both paths, delete its
+# conflict copies, and make the two versions differ. The next run renames the
+# file to the same conflict names that were just deleted on both paths.
+
+test initial bisync
+bisync resync
+
+test changed on both paths and NOT identical - file1 (file1R, file1L)
+touch-glob 2001-01-02 {datadir/} file1R.txt
+copy-as {datadir/}file1R.txt {path2/} file1.txt
+touch-glob 2001-03-04 {datadir/} file1L.txt
+copy-as {datadir/}file1L.txt {path1/} file1.txt
+
+test bisync run with --conflict-resolve=none --conflict-loser=num
+# result should be "file1.txt.conflict1", "file1.txt.conflict2" on both paths
+bisync conflict-resolve=none conflict-loser=num conflict-suffix=conflict
+
+test restore file1.txt on both paths, NOT identical, and delete the conflict copies
+delete-file {path1/}file1.txt.conflict1
+delete-file {path1/}file1.txt.conflict2
+delete-file {path2/}file1.txt.conflict1
+delete-file {path2/}file1.txt.conflict2
+touch-glob 2002-01-02 {datadir/} file1R.txt
+copy-as {datadir/}file1R.txt {path2/} file1.txt
+touch-glob 2002-03-04 {datadir/} file1L.txt
+copy-as {datadir/}file1L.txt {path1/} file1.txt
+
+test bisync run reuses the deleted conflict names
+# result should again be "file1.txt.conflict1", "file1.txt.conflict2" on both paths
+bisync conflict-resolve=none conflict-loser=num conflict-suffix=conflict
+
+test next bisync run has no changes
+bisync