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 conflict winner missing from listings when Path2 wins

nielash9682abe88ebe
diff --git a/cmd/bisync/listing.go b/cmd/bisync/listing.go
index 282565ff6..c57928557 100644
--- a/cmd/bisync/listing.go
+++ b/cmd/bisync/listing.go
@@ -617,10 +617,11 @@ func (b *bisyncRun) modifyListing(ctx context.Context, src fs.Fs, dst fs.Fs, res
srcList.put(srcNewName, new.size, new.time, new.hash, new.id, new.flags)
dstList.put(srcNewName, new.size, new.time, new.hash, new.id, new.flags)
}
- if srcNewName != srcOldName {
+ // the winner of a conflict keeps the old name and is copied to the other side
+ if srcNewName != srcOldName && dstNewName != srcOldName {
srcList.remove(srcOldName)
}
- if srcNewName != dstOldName {
+ if srcNewName != dstOldName && dstNewName != dstOldName {
dstList.remove(dstOldName)
}
}
diff --git a/cmd/bisync/testdata/test_resolve/golden/_testdir_path1.._testdir_path2.path1.lst-old b/cmd/bisync/testdata/test_resolve/golden/_testdir_path1.._testdir_path2.path1.lst-old
index 57872a027..fb238e4ce 100644
--- a/cmd/bisync/testdata/test_resolve/golden/_testdir_path1.._testdir_path2.path1.lst-old
+++ b/cmd/bisync/testdata/test_resolve/golden/_testdir_path1.._testdir_path2.path1.lst-old
@@ -8,3 +8,4 @@
- 33 - - 2003-07-23T00:00:00.000000000+0000 "file1.txt.cloud1"
- 33 - - 2001-08-26T00:00:00.000000000+0000 "file1.txt.dinosaur1"
- 33 - - 2003-07-23T00:00:00.000000000+0000 "file1.txt.local1"
+- 33 - - 2006-03-04T00:00:00.000000000+0000 "file2.txt"
diff --git a/cmd/bisync/testdata/test_resolve/golden/_testdir_path1.._testdir_path2.path2.lst-old b/cmd/bisync/testdata/test_resolve/golden/_testdir_path1.._testdir_path2.path2.lst-old
index 57872a027..fb238e4ce 100644
--- a/cmd/bisync/testdata/test_resolve/golden/_testdir_path1.._testdir_path2.path2.lst-old
+++ b/cmd/bisync/testdata/test_resolve/golden/_testdir_path1.._testdir_path2.path2.lst-old
@@ -8,3 +8,4 @@
- 33 - - 2003-07-23T00:00:00.000000000+0000 "file1.txt.cloud1"
- 33 - - 2001-08-26T00:00:00.000000000+0000 "file1.txt.dinosaur1"
- 33 - - 2003-07-23T00:00:00.000000000+0000 "file1.txt.local1"
+- 33 - - 2006-03-04T00:00:00.000000000+0000 "file2.txt"
diff --git a/cmd/bisync/testdata/test_resolve/golden/test.log b/cmd/bisync/testdata/test_resolve/golden/test.log
index fb4d03c0c..8aaf9a751 100644
--- a/cmd/bisync/testdata/test_resolve/golden/test.log
+++ b/cmd/bisync/testdata/test_resolve/golden/test.log
@@ -137,11 +137,13 @@ INFO : Bisyncing with Comparison Settings:
INFO : Synching Path1 "{path1/}" with Path2 "{path2/}"
INFO : Building Path1 and Path2 listings
INFO : Path1 checking for diffs
-INFO : - Path1 File is new - file1.txt
-INFO : Path1: 1 changes:  1 new,  0 modified,  0 deleted
+INFO : - Path1 File changed: time (newer) - file1.txt
+INFO : Path1: 1 changes:  0 new,  1 modified,  0 deleted
+INFO : (Modified:  1 newer,  0 older)
INFO : Path2 checking for diffs
-INFO : - Path2 File is new - file1.txt
-INFO : Path2: 1 changes:  1 new,  0 modified,  0 deleted
+INFO : - Path2 File changed: time (newer) - file1.txt
+INFO : Path2: 1 changes:  0 new,  1 modified,  0 deleted
+INFO : (Modified:  1 newer,  0 older)
INFO : Applying changes
INFO : Checking potential conflicts...
ERROR : file1.txt: {hashtype} differ
@@ -149,7 +151,7 @@ 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
-INFO : file1.txt: Winner cannot be determined as sizes are equal. Path1: 33, Path2: 33, Difference: 0
+INFO : file1.txt: Winner cannot be determined as sizes are equal. Path1: 0, Path2: 0, Difference: 0
INFO : file1.txt: A winner could not be determined.
NOTICE: - Path1 Renaming Path1 copy - {path1/}file1.txt.apple1
NOTICE: - Path1 Queue copy to Path2 - {path2/}file1.txt.apple1
@@ -329,20 +331,17 @@ INFO : Synching Path1 "{path1/}" with Path2 "{path2/}"
INFO : Building Path1 and Path2 listings
INFO : Path1 checking for diffs
INFO : - Path1 File changed: time (older) - file1.txt
-INFO : - Path1 File is new - file2.txt
-INFO : Path1: 2 changes:  1 new,  1 modified,  0 deleted
+INFO : Path1: 1 changes:  0 new,  1 modified,  0 deleted
INFO : (Modified:  0 newer,  1 older)
INFO : Path2 checking for diffs
INFO : - Path2 File changed: time (older) - file1.txt
-INFO : - Path2 File is new - file2.txt
-INFO : Path2: 2 changes:  1 new,  1 modified,  0 deleted
+INFO : Path2: 1 changes:  0 new,  1 modified,  0 deleted
INFO : (Modified:  0 newer,  1 older)
INFO : Applying changes
INFO : Checking potential conflicts...
ERROR : file1.txt: {hashtype} differ
NOTICE: {path2String}: 1 differences found
NOTICE: {path2String}: 1 errors while checking
-NOTICE: {path2String}: 1 matching files
INFO : Finished checking the potential conflicts. 1 differences found
NOTICE: - WARNING New or changed in both paths - file1.txt
INFO : file1.txt: Path1 is newer. Path1: 2004-07-25 00:00:00 +0000 UTC, Path2: 2004-07-23 00:00:00 +0000 UTC, Difference: 48h0m0s
@@ -351,8 +350,6 @@ NOTICE: - Path1 Not renaming Path1 copy, as it was determined t
NOTICE: - Path1 Queue copy to Path2 - {path2/}file1.txt
NOTICE: - Path2 Renaming Path2 copy - {path2/}file1.txt.path2
NOTICE: - Path2 Queue copy to Path1 - {path1/}file1.txt.path2
-NOTICE: - WARNING New or changed in both paths - file2.txt
-INFO : Files are equal! Skipping: file2.txt
INFO : - Path2 Do queued copies to - Path1
INFO : - Path1 Do queued copies to - Path2
INFO : Updating listings
diff --git a/docs/content/bisync.md b/docs/content/bisync.md
index 0f7382d78..6d3f42a0a 100644
--- a/docs/content/bisync.md
+++ b/docs/content/bisync.md
@@ -1937,6 +1937,8 @@ about *Unison* and synchronization in general.
- Added `--max-delete-renames-aware` to exclude guaranteed tracked renames from
the `--max-delete` safety check when used with `--track-renames`.
+- Fixed an issue causing the conflict winner to be missing from listings when
+Path2 won.
### `v1.74.2`