bisync: fix --conflict-loser pathname with --conflict-resolve newer

Before this change, --conflict-loser pathname assumed --conflict-resolve none,
following the legacy behavior prior to v1.66. This produced unexpected behavior
when used with a different --conflict-resolve option.

This change fixes the issue by ensuring that --conflict-loser pathname looks for
the correct name on the side not being renamed, when only one side should be
renamed.

https://forum.rclone.org/t/bisync-does-not-copy-the-winner-file-to-the-loser-site/53768
This commit is contained in:
nielash
2026-05-10 23:49:03 -04:00
parent acda43a74f
commit 35752d0079
11 changed files with 91 additions and 9 deletions

View File

@@ -165,6 +165,16 @@ func (b *bisyncRun) resolve(ctxMove context.Context, path1, path2, file, alias s
},
}
if b.opt.ConflictLoser == ConflictLoserPathname {
switch winningPath {
case 1: // keep path1, rename path2
r.path1.newName = r.path1.oldName
case 2: // keep path2, rename path1
r.path2.newName = r.path2.oldName
}
// case 0 keeps default
}
// handle auto-numbering
// note that we still queue copies for both files, whether or not we renamed
// we also set these for ConflictLoserDelete in case there is no winner.

View File

@@ -1 +1 @@
"file2.txt"
"file1.txt.path2"

View File

@@ -1,6 +1,6 @@
# bisync listing v1 from test
- 109 - - 2000-01-01T00:00:00.000000000+0000 "RCLONE_TEST"
- 33 - - 2006-03-04T00:00:00.000000000+0000 "file1.txt"
- 33 - - 2004-07-25T00:00:00.000000000+0000 "file1.txt"
- 33 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt..path1"
- 33 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt..path2"
- 33 - - 2002-08-26T00:00:00.000000000+0000 "file1.txt.apple1"
@@ -8,3 +8,5 @@
- 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 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt.path2"
- 33 - - 2006-03-04T00:00:00.000000000+0000 "file2.txt"

View File

@@ -1,6 +1,6 @@
# bisync listing v1 from test
- 109 - - 2000-01-01T00:00:00.000000000+0000 "RCLONE_TEST"
- 33 - - 2006-03-04T00:00:00.000000000+0000 "file1.txt"
- 33 - - 2004-07-25T00:00:00.000000000+0000 "file1.txt"
- 33 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt..path1"
- 33 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt..path2"
- 33 - - 2002-08-26T00:00:00.000000000+0000 "file1.txt.apple1"
@@ -8,4 +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 - - 2005-01-02T00:00:00.000000000+0000 "file2.txt"
- 33 - - 2006-03-04T00:00:00.000000000+0000 "file2.txt"

View File

@@ -1,5 +1,6 @@
# bisync listing v1 from test
- 109 - - 2000-01-01T00:00:00.000000000+0000 "RCLONE_TEST"
- 33 - - 2006-03-04T00:00:00.000000000+0000 "file1.txt"
- 33 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt..path1"
- 33 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt..path2"
- 33 - - 2002-08-26T00:00:00.000000000+0000 "file1.txt.apple1"
@@ -7,4 +8,3 @@
- 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"
- 0 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"

View File

@@ -1,6 +1,6 @@
# bisync listing v1 from test
- 109 - - 2000-01-01T00:00:00.000000000+0000 "RCLONE_TEST"
- 33 - - 2006-03-04T00:00:00.000000000+0000 "file1.txt"
- 33 - - 2004-07-25T00:00:00.000000000+0000 "file1.txt"
- 33 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt..path1"
- 33 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt..path2"
- 33 - - 2002-08-26T00:00:00.000000000+0000 "file1.txt.apple1"
@@ -8,3 +8,5 @@
- 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 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt.path2"
- 33 - - 2006-03-04T00:00:00.000000000+0000 "file2.txt"

View File

@@ -1,6 +1,6 @@
# bisync listing v1 from test
- 109 - - 2000-01-01T00:00:00.000000000+0000 "RCLONE_TEST"
- 33 - - 2005-01-02T00:00:00.000000000+0000 "file1.txt"
- 33 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt"
- 33 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt..path1"
- 33 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt..path2"
- 33 - - 2002-08-26T00:00:00.000000000+0000 "file1.txt.apple1"

View File

@@ -1,5 +1,6 @@
# bisync listing v1 from test
- 109 - - 2000-01-01T00:00:00.000000000+0000 "RCLONE_TEST"
- 33 - - 2006-03-04T00:00:00.000000000+0000 "file1.txt"
- 33 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt..path1"
- 33 - - 2004-07-23T00:00:00.000000000+0000 "file1.txt..path2"
- 33 - - 2002-08-26T00:00:00.000000000+0000 "file1.txt.apple1"
@@ -7,4 +8,3 @@
- 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"
- 0 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"

View File

@@ -305,3 +305,56 @@ INFO : - Path1 Do queued copies to - P
INFO : Updating listings
INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}"
INFO : Bisync successful
(48) : test --conflict-resolve newer --conflict-loser pathname --conflict-suffix path
(49) : touch-glob 2004-07-23 {datadir/} file1R.txt
(50) : copy-as {datadir/}file1R.txt {path2/} file1.txt
(51) : touch-glob 2004-07-25 {datadir/} file1L.txt
(52) : copy-as {datadir/}file1L.txt {path1/} file1.txt
(53) : test bisync run with --conflict-resolve=newer --conflict-loser=pathname --conflict-suffix=path
(54) : bisync conflict-resolve=newer conflict-loser=pathname conflict-suffix=path
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: time (older) - file1.txt
INFO : - Path1 File is new - file2.txt
INFO : Path1: 2 changes:  1 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 : (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
INFO : file1.txt: The winner is: Path1
NOTICE: - Path1 Not renaming Path1 copy, as it was determined the winner - {path1/}file1.txt
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
INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}"
INFO : Bisync successful

View File

@@ -64,4 +64,14 @@ copy-as {datadir/}file1L.txt {path1/} file1.txt
copy-as {datadir/}file1L.txt {path2/} file2.txt
test bisync run with --conflict-resolve=newer --conflict-loser=delete
bisync conflict-resolve=newer conflict-loser=delete
bisync conflict-resolve=newer conflict-loser=delete
test --conflict-resolve newer --conflict-loser pathname --conflict-suffix path
touch-glob 2004-07-23 {datadir/} file1R.txt
copy-as {datadir/}file1R.txt {path2/} file1.txt
touch-glob 2004-07-25 {datadir/} file1L.txt
copy-as {datadir/}file1L.txt {path1/} file1.txt
test bisync run with --conflict-resolve=newer --conflict-loser=pathname --conflict-suffix=path
# result should be -- "file1.txt", "file1.txt.path2"
bisync conflict-resolve=newer conflict-loser=pathname conflict-suffix=path

View File

@@ -1899,6 +1899,11 @@ about *Unison* and synchronization in general.
## Changelog
### `v1.74.2`
- Fixed an issue causing `--conflict-loser pathname` to produce unexpected
behavior if using a non-default `--conflict-resolve` value.
### `v1.74`
- Added several missing `rc` parameters.