mirror of
https://github.com/rclone/rclone.git
synced 2026-05-12 10:03:35 -04:00
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:
@@ -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.
|
||||
|
||||
@@ -1 +1 @@
|
||||
"file2.txt"
|
||||
"file1.txt.path2"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
53
cmd/bisync/testdata/test_resolve/golden/test.log
vendored
53
cmd/bisync/testdata/test_resolve/golden/test.log
vendored
@@ -305,3 +305,56 @@ INFO : - [36mPath1[0m [35mDo queued copies to[0m - [36mP
|
||||
INFO : Updating listings
|
||||
INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}"
|
||||
INFO : [32mBisync successful[0m
|
||||
|
||||
[36m(48) :[0m [34mtest --conflict-resolve newer --conflict-loser pathname --conflict-suffix path[0m
|
||||
[36m(49) :[0m [34mtouch-glob 2004-07-23 {datadir/} file1R.txt[0m
|
||||
[36m(50) :[0m [34mcopy-as {datadir/}file1R.txt {path2/} file1.txt[0m
|
||||
[36m(51) :[0m [34mtouch-glob 2004-07-25 {datadir/} file1L.txt[0m
|
||||
[36m(52) :[0m [34mcopy-as {datadir/}file1L.txt {path1/} file1.txt[0m
|
||||
|
||||
[36m(53) :[0m [34mtest bisync run with --conflict-resolve=newer --conflict-loser=pathname --conflict-suffix=path[0m
|
||||
|
||||
[36m(54) :[0m [34mbisync conflict-resolve=newer conflict-loser=pathname conflict-suffix=path[0m
|
||||
INFO : [2mSetting --ignore-listing-checksum as neither --checksum nor --compare checksum are set.[0m
|
||||
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 : - [36mPath1[0m [35m[33mFile changed: [35mtime (older)[0m[0m[0m - [36mfile1.txt[0m
|
||||
INFO : - [36mPath1[0m [35m[32mFile is new[0m[0m - [36mfile2.txt[0m
|
||||
INFO : Path1: 2 changes: [32m 1 new[0m, [33m 1 modified[0m, [31m 0 deleted[0m
|
||||
INFO : ([33mModified[0m: [36m 0 newer[0m, [34m 1 older[0m)
|
||||
INFO : Path2 checking for diffs
|
||||
INFO : - [34mPath2[0m [35m[33mFile changed: [35mtime (older)[0m[0m[0m - [36mfile1.txt[0m
|
||||
INFO : - [34mPath2[0m [35m[32mFile is new[0m[0m - [36mfile2.txt[0m
|
||||
INFO : Path2: 2 changes: [32m 1 new[0m, [33m 1 modified[0m, [31m 0 deleted[0m
|
||||
INFO : ([33mModified[0m: [36m 0 newer[0m, [34m 1 older[0m)
|
||||
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: - [34mWARNING[0m [35mNew or changed in both paths[0m - [36mfile1.txt[0m
|
||||
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: [32mThe winner is: Path1[0m
|
||||
NOTICE: - [36mPath1[0m [35mNot renaming Path1 copy, as it was determined the winner[0m - [36m{path1/}file1.txt[0m
|
||||
NOTICE: - [36mPath1[0m [35m[32mQueue copy to[0m Path2[0m - [36m{path2/}file1.txt[0m
|
||||
NOTICE: - [34mPath2[0m [35mRenaming Path2 copy[0m - [36m{path2/}file1.txt.path2[0m
|
||||
NOTICE: - [34mPath2[0m [35m[32mQueue copy to[0m Path1[0m - [36m{path1/}file1.txt.path2[0m
|
||||
NOTICE: - [34mWARNING[0m [35mNew or changed in both paths[0m - [36mfile2.txt[0m
|
||||
INFO : Files are equal! Skipping: file2.txt
|
||||
INFO : - [34mPath2[0m [35mDo queued copies to[0m - [36mPath1[0m
|
||||
INFO : - [36mPath1[0m [35mDo queued copies to[0m - [36mPath2[0m
|
||||
INFO : Updating listings
|
||||
INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}"
|
||||
INFO : [32mBisync successful[0m
|
||||
|
||||
12
cmd/bisync/testdata/test_resolve/scenario.txt
vendored
12
cmd/bisync/testdata/test_resolve/scenario.txt
vendored
@@ -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
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user