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: make --max-delete aware of --track-renames

Morax49158b2d9f62
diff --git a/cmd/bisync/bisync_test.go b/cmd/bisync/bisync_test.go
index ddf8438ca..f360bab05 100644
--- a/cmd/bisync/bisync_test.go
+++ b/cmd/bisync/bisync_test.go
@@ -154,6 +154,9 @@ var logHoppers = []string{
// Directory modification time setting can happen in any order
`INFO : .*: (Set directory modification time|Made directory with metadata).*`,
+
+ // Tracked renames can finish in any order.
+ `INFO : .*: Renamed from .*`,
}
// Some log lines can contain Windows path separator that must be
@@ -1002,6 +1005,12 @@ func (b *bisyncTest) checkPreReqs(ctx context.Context, opt *bisync.Options) (con
if strings.HasPrefix(b.fs2.String(), "sftp") {
b.fs2.Features().Disable("Copy") // disable --sftp-copy-is-hardlink as hardlinks are not truly copies
}
+ if b.testCase == "max_delete_track_renames" && (!operations.CanServerSideMove(b.fs1) || !operations.CanServerSideMove(b.fs2)) {
+ b.t.Skip("skipping test as at least one remote does not support server-side move or copy")
+ }
+ if b.testCase == "max_delete_track_renames" && b.fs1.Hashes().Overlap(b.fs2.Hashes()).GetOne() == hash.None {
+ b.t.Skip("skipping test as the two remotes have no hash in common")
+ }
if strings.Contains(strings.ToLower(fs.ConfigString(b.fs1)), "mailru") || strings.Contains(strings.ToLower(fs.ConfigString(b.fs2)), "mailru") {
fs.GetConfig(ctx).TPSLimit = 10 // https://github.com/rclone/rclone/issues/7768#issuecomment-2060888980
}
@@ -1152,6 +1161,12 @@ func (b *bisyncTest) runBisync(ctx context.Context, args []string) (err error) {
case "max-delete":
opt.MaxDelete, err = strconv.Atoi(val)
require.NoError(b.t, err, "parsing max-delete=%q", val)
+ case "max-delete-renames-aware":
+ opt.MaxDeleteRenamesAware = true
+ case "track-renames":
+ ci.TrackRenames = true
+ case "track-renames-strategy":
+ ci.TrackRenamesStrategy = val
case "size-only":
ci.SizeOnly = true
case "ignore-size":
@@ -1647,6 +1662,10 @@ func (b *bisyncTest) mangleResult(dir, file string, golden bool) string {
)
}
rep := logReplacements
+ if b.testCase == "max_delete_track_renames" && (b.fs1.Features().Move == nil || b.fs2.Features().Move == nil) {
+ // Without server-side Move, a tracked rename is a server-side copy + delete, counted as a transfer.
+ rep = append(rep, `^.*There was nothing to transfer.*$`, dropMe)
+ }
if b.testCase == "dry_run" {
rep = append(rep, dryrunReplacements...)
}
diff --git a/cmd/bisync/cmd.go b/cmd/bisync/cmd.go
index f1b3367bb..2abc450fa 100644
--- a/cmd/bisync/cmd.go
+++ b/cmd/bisync/cmd.go
@@ -39,6 +39,7 @@ type Options struct {
CreateEmptySrcDirs bool
RemoveEmptyDirs bool
MaxDelete int // percentage from 0 to 100
+ MaxDeleteRenamesAware bool
Force bool
FiltersFile string
Workdir string
@@ -130,6 +131,7 @@ func init() {
flags.BoolVarP(cmdFlags, &Opt.CheckAccess, "check-access", "", Opt.CheckAccess, MakeHelp("Ensure expected {CHECKFILE} files are found on both Path1 and Path2 filesystems, else abort."), "")
flags.StringVarP(cmdFlags, &Opt.CheckFilename, "check-filename", "", Opt.CheckFilename, MakeHelp("Filename for --check-access (default: {CHECKFILE})"), "")
flags.BoolVarP(cmdFlags, &Opt.Force, "force", "", Opt.Force, "Bypass --max-delete safety check and run the sync. Consider using with --verbose", "")
+ flags.BoolVarP(cmdFlags, &Opt.MaxDeleteRenamesAware, "max-delete-renames-aware", "", Opt.MaxDeleteRenamesAware, "Exclude tracked renames from the --max-delete safety check (requires --track-renames)", "")
flags.FVarP(cmdFlags, &Opt.CheckSync, "check-sync", "", "Controls comparison of final listings: true|false|only (default: true)", "")
flags.BoolVarP(cmdFlags, &Opt.CreateEmptySrcDirs, "create-empty-src-dirs", "", Opt.CreateEmptySrcDirs, "Sync creation and deletion of empty directories. (Not compatible with --remove-empty-dirs)", "")
flags.BoolVarP(cmdFlags, &Opt.RemoveEmptyDirs, "remove-empty-dirs", "", Opt.RemoveEmptyDirs, "Remove ALL empty directories at the final cleanup step.", "")
diff --git a/cmd/bisync/compare.go b/cmd/bisync/compare.go
index 9334bec7f..a8c94366b 100644
--- a/cmd/bisync/compare.go
+++ b/cmd/bisync/compare.go
@@ -30,6 +30,7 @@ type CompareOpt = struct {
func (b *bisyncRun) setCompareDefaults(ctx context.Context) (err error) {
ci := fs.GetConfig(ctx)
+ renameHash := b.trackRenamesPreflight() && b.trackRenamesStrategy.UsesHash()
// defaults
b.opt.Compare.Size = true
@@ -58,7 +59,16 @@ func (b *bisyncRun) setCompareDefaults(ctx context.Context) (err error) {
if b.fs1.Features().SlowHash || b.fs2.Features().SlowHash {
b.opt.Compare.SlowHashDetected = true
}
- if b.opt.Compare.Checksum && !b.opt.IgnoreListingChecksum {
+ if renameHash && b.opt.IgnoreListingChecksum {
+ return errors.New("--max-delete-renames-aware with a hash strategy is incompatible with --ignore-listing-checksum")
+ }
+ if renameHash && b.opt.Compare.SlowHashDetected && (b.opt.Compare.NoSlowHash || b.opt.Compare.SlowHashSyncOnly) {
+ return errors.New("--max-delete-renames-aware with a hash strategy is incompatible with the configured slow-hash exclusions")
+ }
+ if renameHash && b.fs1.Hashes().Overlap(b.fs2.Hashes()).GetOne() == hash.None {
+ return errors.New("--max-delete-renames-aware with a hash strategy requires a common hash on both paths")
+ }
+ if (b.opt.Compare.Checksum || renameHash) && !b.opt.IgnoreListingChecksum {
b.setHashType(ci)
}
@@ -86,7 +96,7 @@ func (b *bisyncRun) setCompareDefaults(ctx context.Context) (err error) {
// note: --checksum will still affect the internal sync calls
}
}
- if !ci.CheckSum && !b.opt.Compare.Checksum && !b.opt.IgnoreListingChecksum {
+ if !ci.CheckSum && !b.opt.Compare.Checksum && !b.opt.IgnoreListingChecksum && !renameHash {
fs.Infoc(nil, Color(terminal.Dim, "Setting --ignore-listing-checksum as neither --checksum nor --compare checksum are set."))
b.opt.IgnoreListingChecksum = true
}
diff --git a/cmd/bisync/deltas.go b/cmd/bisync/deltas.go
index fa5ea785e..c9ab491c5 100644
--- a/cmd/bisync/deltas.go
+++ b/cmd/bisync/deltas.go
@@ -44,17 +44,18 @@ func (d delta) is(cond delta) bool {
// deltaSet
type deltaSet struct {
- deltas map[string]delta
- size map[string]int64
- time map[string]time.Time
- hash map[string]string
- opt *Options
- fs fs.Fs // base filesystem
- msg string // filesystem name for logging
- oldCount int // original number of files (for "excess deletes" check)
- deleted int // number of deleted files (for "excess deletes" check)
- foundSame bool // true if found at least one unchanged file
- checkFiles bilib.Names
+ deltas map[string]delta
+ size map[string]int64
+ time map[string]time.Time
+ hash map[string]string
+ opt *Options
+ fs fs.Fs // base filesystem
+ msg string // filesystem name for logging
+ oldCount int // original number of files (for "excess deletes" check)
+ deleted int // number of deleted files (for "excess deletes" check)
+ renameExemptions int // tracked renames excluded from the max-delete check
+ foundSame bool // true if found at least one unchanged file
+ checkFiles bilib.Names
}
func (ds *deltaSet) empty() bool {
@@ -541,22 +542,38 @@ func (b *bisyncRun) applyDeltas(ctx context.Context, ds1, ds2 *deltaSet) (result
return
}
-// excessDeletes checks whether number of deletes is within allowed range
-func (ds *deltaSet) excessDeletes() bool {
+func (ds *deltaSet) effectiveDeletes() int {
+ return max(0, ds.deleted-ds.renameExemptions)
+}
+
+func (ds *deltaSet) exceedsDeletes() bool {
maxDelete := ds.opt.MaxDelete
maxRatio := float64(maxDelete) / 100.0
curRatio := 0.0
- if ds.deleted > 0 && ds.oldCount > 0 {
- curRatio = float64(ds.deleted) / float64(ds.oldCount)
+ effectiveDeletes := ds.effectiveDeletes()
+ if effectiveDeletes > 0 && ds.oldCount > 0 {
+ curRatio = float64(effectiveDeletes) / float64(ds.oldCount)
}
+ return curRatio > maxRatio
+}
- if curRatio <= maxRatio {
+// excessDeletes checks whether number of deletes is within allowed range
+func (ds *deltaSet) excessDeletes() bool {
+ if !ds.exceedsDeletes() {
return false
}
+ maxDelete := ds.opt.MaxDelete
+ effectiveDeletes := ds.effectiveDeletes()
+ if ds.renameExemptions > 0 {
+ fs.Errorf("Safety abort",
+ "too many deletes (>%d%%, %d of %d after excluding %d tracked renames) on %s %s. Run with --force if desired.",
+ maxDelete, effectiveDeletes, ds.oldCount, ds.renameExemptions, ds.msg, quotePath(bilib.FsPath(ds.fs)))
+ return true
+ }
fs.Errorf("Safety abort",
"too many deletes (>%d%%, %d of %d) on %s %s. Run with --force if desired.",
- maxDelete, ds.deleted, ds.oldCount, ds.msg, quotePath(bilib.FsPath(ds.fs)))
+ maxDelete, effectiveDeletes, ds.oldCount, ds.msg, quotePath(bilib.FsPath(ds.fs)))
return true
}
diff --git a/cmd/bisync/march.go b/cmd/bisync/march.go
index 10e22dc38..3bd52ca79 100644
--- a/cmd/bisync/march.go
+++ b/cmd/bisync/march.go
@@ -160,7 +160,7 @@ func (b *bisyncRun) ForObject(o fs.Object, isPath1 bool) {
b.march.marchErrLock.Unlock()
var modtime time.Time
- if b.opt.Compare.Modtime {
+ if b.opt.Compare.Modtime || (b.trackRenamesPreflight() && b.trackRenamesStrategy.UsesModtime()) {
modtime = o.ModTime(b.march.marchCtx).In(TZ)
}
id := "" // TODO: ID(o)
diff --git a/cmd/bisync/operations.go b/cmd/bisync/operations.go
index a7f648995..2c8b1d173 100644
--- a/cmd/bisync/operations.go
+++ b/cmd/bisync/operations.go
@@ -19,6 +19,7 @@ import (
"github.com/rclone/rclone/fs/accounting"
"github.com/rclone/rclone/fs/log"
"github.com/rclone/rclone/fs/operations"
+ "github.com/rclone/rclone/fs/sync/trackrenames"
"github.com/rclone/rclone/lib/atexit"
"github.com/rclone/rclone/lib/terminal"
)
@@ -28,34 +29,35 @@ var ErrBisyncAborted = errors.New("bisync aborted")
// bisyncRun keeps bisync runtime state
type bisyncRun struct {
- fs1 fs.Fs
- fs2 fs.Fs
- abort bool
- critical bool
- retryable bool
- basePath string
- workDir string
- listing1 string
- listing2 string
- newListing1 string
- newListing2 string
- aliases bilib.AliasMap
- opt *Options
- octx context.Context
- fctx context.Context
- InGracefulShutdown bool
- CleanupCompleted bool
- SyncCI *fs.ConfigInfo
- CancelSync context.CancelFunc
- DebugName string
- lockFile string
- renames renames
- resyncIs1to2 bool
- march bisyncMarch
- check bisyncCheck
- queueOpt bisyncQueueOpt
- downloadHashOpt downloadHashOpt
- lockFileOpt lockFileOpt
+ fs1 fs.Fs
+ fs2 fs.Fs
+ abort bool
+ critical bool
+ retryable bool
+ basePath string
+ workDir string
+ listing1 string
+ listing2 string
+ newListing1 string
+ newListing2 string
+ aliases bilib.AliasMap
+ opt *Options
+ octx context.Context
+ fctx context.Context
+ InGracefulShutdown bool
+ CleanupCompleted bool
+ SyncCI *fs.ConfigInfo
+ CancelSync context.CancelFunc
+ DebugName string
+ lockFile string
+ renames renames
+ resyncIs1to2 bool
+ march bisyncMarch
+ check bisyncCheck
+ queueOpt bisyncQueueOpt
+ downloadHashOpt downloadHashOpt
+ lockFileOpt lockFileOpt
+ trackRenamesStrategy trackrenames.Strategy
}
type queues struct {
@@ -85,6 +87,15 @@ func Bisync(ctx context.Context, fs1, fs2 fs.Fs, optArg *Options) (err error) {
}
ci := fs.GetConfig(ctx)
opt.OrigBackupDir = ci.BackupDir
+ if opt.MaxDeleteRenamesAware {
+ if !ci.TrackRenames {
+ return errors.New("--max-delete-renames-aware requires --track-renames")
+ }
+ b.trackRenamesStrategy, err = trackrenames.ParseStrategy(ci.TrackRenamesStrategy)
+ if err != nil {
+ return err
+ }
+ }
if ci.TerminalColorMode == fs.TerminalColorModeAlways || (ci.TerminalColorMode == fs.TerminalColorModeAuto && !log.Redirected()) {
ColorsLock.Lock()
@@ -346,6 +357,18 @@ func (b *bisyncRun) runLocked(octx context.Context) (err error) {
// Check for too many deleted files - possible error condition.
// Don't want to start deleting on the other side!
if !opt.Force {
+ if b.trackRenamesPreflight() && (ds1.exceedsDeletes() || ds2.exceedsDeletes()) {
+ ds1.renameExemptions, ds2.renameExemptions, err = b.trackedRenameExemptions(fctx, ds1, ds2)
+ if err != nil {
+ return err
+ }
+ if ds1.renameExemptions > 0 {
+ fs.Infof(nil, "Path1: excluding %d tracked renames from --max-delete", ds1.renameExemptions)
+ }
+ if ds2.renameExemptions > 0 {
+ fs.Infof(nil, "Path2: excluding %d tracked renames from --max-delete", ds2.renameExemptions)
+ }
+ }
if ds1.excessDeletes() || ds2.excessDeletes() {
b.abort = true
return errors.New("too many deletes")
diff --git a/cmd/bisync/rc.go b/cmd/bisync/rc.go
index 82be54185..fd1a67e1c 100644
--- a/cmd/bisync/rc.go
+++ b/cmd/bisync/rc.go
@@ -90,6 +90,9 @@ func rcBisync(ctx context.Context, in rc.Params) (out rc.Params, err error) {
if opt.Force, err = in.GetBool("force"); rc.NotErrParamNotFound(err) {
fs.Debugf("force", "optional parameter is missing. using default value: %v", opt.Force)
}
+ if opt.MaxDeleteRenamesAware, err = in.GetBool("maxDeleteRenamesAware"); rc.NotErrParamNotFound(err) {
+ fs.Debugf("maxDeleteRenamesAware", "optional parameter is missing. using default value: %v", opt.MaxDeleteRenamesAware)
+ }
if opt.CreateEmptySrcDirs, err = in.GetBool("createEmptySrcDirs"); rc.NotErrParamNotFound(err) {
fs.Debugf("createEmptySrcDirs", "optional parameter is missing. using default value: %v", opt.CreateEmptySrcDirs)
}
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.copy1to2.que b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.copy1to2.que
new file mode 100644
index 000000000..82057a801
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.copy1to2.que
@@ -0,0 +1,8 @@
+"file6.txt"
+"file7.txt"
+"moved-file1.txt"
+"renamed2-file1.txt"
+"renamed2-file2.txt"
+"renamed2-file3.txt"
+"renamed2-file4.txt"
+"renamed2-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.copy2to1.que b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.copy2to1.que
new file mode 100644
index 000000000..9f8498d70
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.copy2to1.que
@@ -0,0 +1,10 @@
+"renamed-file1.txt"
+"renamed-file2.txt"
+"renamed-file3.txt"
+"renamed-file4.txt"
+"renamed-file5.txt"
+"renamed2-file1.txt"
+"renamed2-file2.txt"
+"renamed2-file3.txt"
+"renamed2-file4.txt"
+"renamed2-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.delete1.que b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.delete1.que
new file mode 100644
index 000000000..6c9923c45
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.delete1.que
@@ -0,0 +1,5 @@
+"renamed-file1.txt"
+"renamed-file2.txt"
+"renamed-file3.txt"
+"renamed-file4.txt"
+"renamed-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.delete2.que b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.delete2.que
new file mode 100644
index 000000000..88eb3949f
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.delete2.que
@@ -0,0 +1,7 @@
+"file6.txt"
+"file7.txt"
+"renamed2-file1.txt"
+"renamed2-file2.txt"
+"renamed2-file3.txt"
+"renamed2-file4.txt"
+"renamed2-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path1.lst b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path1.lst
new file mode 100644
index 000000000..c9f6b51a0
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path1.lst
@@ -0,0 +1,4 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "moved-file1.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path1.lst-new b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path1.lst-new
new file mode 100644
index 000000000..c9f6b51a0
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path1.lst-new
@@ -0,0 +1,4 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "moved-file1.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path1.lst-old b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path1.lst-old
new file mode 100644
index 000000000..53e2547d8
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path1.lst-old
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path2.lst b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path2.lst
new file mode 100644
index 000000000..c9f6b51a0
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path2.lst
@@ -0,0 +1,4 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "moved-file1.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path2.lst-new b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path2.lst-new
new file mode 100644
index 000000000..53e2547d8
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path2.lst-new
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path2.lst-old b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path2.lst-old
new file mode 100644
index 000000000..53e2547d8
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/_testdir_path1.._testdir_path2.path2.lst-old
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/ignore-hash-fail._testdir_path1.._testdir_path2.path1.lst b/cmd/bisync/testdata/test_max_delete_track_renames/golden/ignore-hash-fail._testdir_path1.._testdir_path2.path1.lst
new file mode 100644
index 000000000..57873961f
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/ignore-hash-fail._testdir_path1.._testdir_path2.path1.lst
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/ignore-hash-fail._testdir_path1.._testdir_path2.path1.lst-new b/cmd/bisync/testdata/test_max_delete_track_renames/golden/ignore-hash-fail._testdir_path1.._testdir_path2.path1.lst-new
new file mode 100644
index 000000000..4f98654dc
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/ignore-hash-fail._testdir_path1.._testdir_path2.path1.lst-new
@@ -0,0 +1 @@
+# bisync listing v1 from test
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/ignore-hash-fail._testdir_path1.._testdir_path2.path2.lst b/cmd/bisync/testdata/test_max_delete_track_renames/golden/ignore-hash-fail._testdir_path1.._testdir_path2.path2.lst
new file mode 100644
index 000000000..57873961f
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/ignore-hash-fail._testdir_path1.._testdir_path2.path2.lst
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/ignore-hash-fail._testdir_path1.._testdir_path2.path2.lst-new b/cmd/bisync/testdata/test_max_delete_track_renames/golden/ignore-hash-fail._testdir_path1.._testdir_path2.path2.lst-new
new file mode 100644
index 000000000..4f98654dc
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/ignore-hash-fail._testdir_path1.._testdir_path2.path2.lst-new
@@ -0,0 +1 @@
+# bisync listing v1 from test
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/initial-fail._testdir_path1.._testdir_path2.path1.lst b/cmd/bisync/testdata/test_max_delete_track_renames/golden/initial-fail._testdir_path1.._testdir_path2.path1.lst
new file mode 100644
index 000000000..57873961f
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/initial-fail._testdir_path1.._testdir_path2.path1.lst
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/initial-fail._testdir_path1.._testdir_path2.path1.lst-new b/cmd/bisync/testdata/test_max_delete_track_renames/golden/initial-fail._testdir_path1.._testdir_path2.path1.lst-new
new file mode 100644
index 000000000..1b52519c7
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/initial-fail._testdir_path1.._testdir_path2.path1.lst-new
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/initial-fail._testdir_path1.._testdir_path2.path2.lst b/cmd/bisync/testdata/test_max_delete_track_renames/golden/initial-fail._testdir_path1.._testdir_path2.path2.lst
new file mode 100644
index 000000000..57873961f
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/initial-fail._testdir_path1.._testdir_path2.path2.lst
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/initial-fail._testdir_path1.._testdir_path2.path2.lst-new b/cmd/bisync/testdata/test_max_delete_track_renames/golden/initial-fail._testdir_path1.._testdir_path2.path2.lst-new
new file mode 100644
index 000000000..57873961f
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/initial-fail._testdir_path1.._testdir_path2.path2.lst-new
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/invalid-strategy-fail._testdir_path1.._testdir_path2.path1.lst b/cmd/bisync/testdata/test_max_delete_track_renames/golden/invalid-strategy-fail._testdir_path1.._testdir_path2.path1.lst
new file mode 100644
index 000000000..57873961f
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/invalid-strategy-fail._testdir_path1.._testdir_path2.path1.lst
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/invalid-strategy-fail._testdir_path1.._testdir_path2.path1.lst-new b/cmd/bisync/testdata/test_max_delete_track_renames/golden/invalid-strategy-fail._testdir_path1.._testdir_path2.path1.lst-new
new file mode 100644
index 000000000..4f98654dc
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/invalid-strategy-fail._testdir_path1.._testdir_path2.path1.lst-new
@@ -0,0 +1 @@
+# bisync listing v1 from test
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/invalid-strategy-fail._testdir_path1.._testdir_path2.path2.lst b/cmd/bisync/testdata/test_max_delete_track_renames/golden/invalid-strategy-fail._testdir_path1.._testdir_path2.path2.lst
new file mode 100644
index 000000000..57873961f
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/invalid-strategy-fail._testdir_path1.._testdir_path2.path2.lst
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/invalid-strategy-fail._testdir_path1.._testdir_path2.path2.lst-new b/cmd/bisync/testdata/test_max_delete_track_renames/golden/invalid-strategy-fail._testdir_path1.._testdir_path2.path2.lst-new
new file mode 100644
index 000000000..4f98654dc
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/invalid-strategy-fail._testdir_path1.._testdir_path2.path2.lst-new
@@ -0,0 +1 @@
+# bisync listing v1 from test
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.copy1to2.que b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.copy1to2.que
new file mode 100644
index 000000000..7b15c76c0
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.copy1to2.que
@@ -0,0 +1,10 @@
+"file1.txt"
+"file2.txt"
+"file3.txt"
+"file4.txt"
+"file5.txt"
+"renamed-file1.txt"
+"renamed-file2.txt"
+"renamed-file3.txt"
+"renamed-file4.txt"
+"renamed-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.copy2to1.que b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.copy2to1.que
new file mode 100644
index 000000000..9f8498d70
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.copy2to1.que
@@ -0,0 +1,10 @@
+"renamed-file1.txt"
+"renamed-file2.txt"
+"renamed-file3.txt"
+"renamed-file4.txt"
+"renamed-file5.txt"
+"renamed2-file1.txt"
+"renamed2-file2.txt"
+"renamed2-file3.txt"
+"renamed2-file4.txt"
+"renamed2-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.delete1.que b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.delete1.que
new file mode 100644
index 000000000..6c9923c45
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.delete1.que
@@ -0,0 +1,5 @@
+"renamed-file1.txt"
+"renamed-file2.txt"
+"renamed-file3.txt"
+"renamed-file4.txt"
+"renamed-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.delete2.que b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.delete2.que
new file mode 100644
index 000000000..9c041c2ba
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.delete2.que
@@ -0,0 +1,5 @@
+"file1.txt"
+"file2.txt"
+"file3.txt"
+"file4.txt"
+"file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path1.lst b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path1.lst
new file mode 100644
index 000000000..53e2547d8
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path1.lst
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path1.lst-new b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path1.lst-new
new file mode 100644
index 000000000..e755063ce
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path1.lst-new
@@ -0,0 +1,4 @@
+# bisync listing v1 from test
+- 20 md5:9f5555d145a19ff064ab19e242759e7e - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 md5:99c6c10d99c3126a3fe64ce7e8319301 - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
+- 20 md5:9d93a157f078ef0ec2d54612a481907e - 2000-01-01T00:00:00.000000000+0000 "moved-file1.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path1.lst-old b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path1.lst-old
new file mode 100644
index 000000000..1b52519c7
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path1.lst-old
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path2.lst b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path2.lst
new file mode 100644
index 000000000..53e2547d8
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path2.lst
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed2-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path2.lst-new b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path2.lst-new
new file mode 100644
index 000000000..66675f78a
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path2.lst-new
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 md5:2b07ff4dfa26b3efa312c7ceaae032a2 - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 md5:ed795af8e94721d1414354b2e3e91914 - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 md5:9f5555d145a19ff064ab19e242759e7e - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 md5:99c6c10d99c3126a3fe64ce7e8319301 - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
+- 20 md5:9d93a157f078ef0ec2d54612a481907e - 2000-01-01T00:00:00.000000000+0000 "renamed2-file1.txt"
+- 20 md5:3da0237956ab1abb278d6931660a2129 - 2000-01-01T00:00:00.000000000+0000 "renamed2-file2.txt"
+- 20 md5:0d509c419d44a022ef9f166d241f1f1e - 2000-01-01T00:00:00.000000000+0000 "renamed2-file3.txt"
+- 20 md5:f430f2f75e2f7525bb81a6c61f389bc9 - 2000-01-01T00:00:00.000000000+0000 "renamed2-file4.txt"
+- 20 md5:c68b022f2fe1e13fa589b10b0f87fdad - 2000-01-01T00:00:00.000000000+0000 "renamed2-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path2.lst-old b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path2.lst-old
new file mode 100644
index 000000000..1b52519c7
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/partial-fail._testdir_path1.._testdir_path2.path2.lst-old
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "renamed-file5.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/requires-track-fail._testdir_path1.._testdir_path2.path1.lst b/cmd/bisync/testdata/test_max_delete_track_renames/golden/requires-track-fail._testdir_path1.._testdir_path2.path1.lst
new file mode 100644
index 000000000..57873961f
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/requires-track-fail._testdir_path1.._testdir_path2.path1.lst
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/requires-track-fail._testdir_path1.._testdir_path2.path1.lst-new b/cmd/bisync/testdata/test_max_delete_track_renames/golden/requires-track-fail._testdir_path1.._testdir_path2.path1.lst-new
new file mode 100644
index 000000000..4f98654dc
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/requires-track-fail._testdir_path1.._testdir_path2.path1.lst-new
@@ -0,0 +1 @@
+# bisync listing v1 from test
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/requires-track-fail._testdir_path1.._testdir_path2.path2.lst b/cmd/bisync/testdata/test_max_delete_track_renames/golden/requires-track-fail._testdir_path1.._testdir_path2.path2.lst
new file mode 100644
index 000000000..57873961f
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/requires-track-fail._testdir_path1.._testdir_path2.path2.lst
@@ -0,0 +1,10 @@
+# bisync listing v1 from test
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file1.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file2.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file3.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file4.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file5.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file6.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file7.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file8.txt"
+- 20 - - 2000-01-01T00:00:00.000000000+0000 "file9.txt"
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/requires-track-fail._testdir_path1.._testdir_path2.path2.lst-new b/cmd/bisync/testdata/test_max_delete_track_renames/golden/requires-track-fail._testdir_path1.._testdir_path2.path2.lst-new
new file mode 100644
index 000000000..4f98654dc
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/requires-track-fail._testdir_path1.._testdir_path2.path2.lst-new
@@ -0,0 +1 @@
+# bisync listing v1 from test
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/golden/test.log b/cmd/bisync/testdata/test_max_delete_track_renames/golden/test.log
new file mode 100644
index 000000000..474f34932
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/golden/test.log
@@ -0,0 +1,276 @@
+(01) : test max-delete-track-renames
+
+
+(02) : test resync bypasses rename-aware hash preflight with ignored listing checksums
+(03) : bisync resync track-renames max-delete-renames-aware ignore-listing-checksum
+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
+ERROR : {path1String}: Ignoring --track-renames as it doesn't work with copy or move, only sync
+INFO : There was nothing to transfer
+INFO : - Path1 Resync is copying files to - Path2
+ERROR : {path2String}: Ignoring --track-renames as it doesn't work with copy or move, only sync
+INFO : There was nothing to transfer
+INFO : Resync updating listings
+INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}"
+INFO : Bisync successful
+
+(04) : test rename-aware max-delete requires track-renames
+(05) : bisync max-delete-renames-aware
+Bisync error: --max-delete-renames-aware requires --track-renames
+(06) : copy-listings requires-track-fail
+
+(07) : test rename-aware max-delete rejects invalid track-renames strategies early
+(08) : bisync track-renames max-delete-renames-aware track-renames-strategy=banana
+Bisync error: unknown track renames strategy "banana"
+(09) : copy-listings invalid-strategy-fail
+
+(10) : test rename-aware hash matching rejects ignored listing checksums
+(11) : bisync track-renames max-delete-renames-aware ignore-listing-checksum
+Bisync error: --max-delete-renames-aware with a hash strategy is incompatible with --ignore-listing-checksum
+(12) : copy-listings ignore-hash-fail
+
+(13) : test rename >50% of Path1 files
+(14) : copy-as {path1/}file1.txt {path1/} renamed-file1.txt
+(15) : delete-file {path1/}file1.txt
+(16) : copy-as {path1/}file2.txt {path1/} renamed-file2.txt
+(17) : delete-file {path1/}file2.txt
+(18) : copy-as {path1/}file3.txt {path1/} renamed-file3.txt
+(19) : delete-file {path1/}file3.txt
+(20) : copy-as {path1/}file4.txt {path1/} renamed-file4.txt
+(21) : delete-file {path1/}file4.txt
+(22) : copy-as {path1/}file5.txt {path1/} renamed-file5.txt
+(23) : delete-file {path1/}file5.txt
+
+(24) : test track-renames alone should retain the max-delete safety abort
+(25) : bisync track-renames
+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
+INFO : - Path1 File was deleted - file2.txt
+INFO : - Path1 File was deleted - file3.txt
+INFO : - Path1 File was deleted - file4.txt
+INFO : - Path1 File was deleted - file5.txt
+INFO : - Path1 File is new - renamed-file1.txt
+INFO : - Path1 File is new - renamed-file2.txt
+INFO : - Path1 File is new - renamed-file3.txt
+INFO : - Path1 File is new - renamed-file4.txt
+INFO : - Path1 File is new - renamed-file5.txt
+INFO : Path1: 10 changes:  5 new,  0 modified,  5 deleted
+INFO : Path2 checking for diffs
+ERROR : Safety abort: too many deletes (>50%, 5 of 9) on Path1 "{path1/}". Run with --force if desired.
+NOTICE: Bisync aborted. Please try again.
+Bisync error: too many deletes
+(26) : copy-listings initial-fail
+
+(27) : test rename-aware max-delete should permit tracked renames
+(28) : bisync track-renames max-delete-renames-aware
+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
+INFO : - Path1 File was deleted - file2.txt
+INFO : - Path1 File was deleted - file3.txt
+INFO : - Path1 File was deleted - file4.txt
+INFO : - Path1 File was deleted - file5.txt
+INFO : - Path1 File is new - renamed-file1.txt
+INFO : - Path1 File is new - renamed-file2.txt
+INFO : - Path1 File is new - renamed-file3.txt
+INFO : - Path1 File is new - renamed-file4.txt
+INFO : - Path1 File is new - renamed-file5.txt
+INFO : Path1: 10 changes:  5 new,  0 modified,  5 deleted
+INFO : Path2 checking for diffs
+INFO : Path1: excluding 5 tracked renames from --max-delete
+INFO : Applying changes
+INFO : - Path2 Queue delete - {path2/}file1.txt
+INFO : - Path2 Queue delete - {path2/}file2.txt
+INFO : - Path2 Queue delete - {path2/}file3.txt
+INFO : - Path2 Queue delete - {path2/}file4.txt
+INFO : - Path2 Queue delete - {path2/}file5.txt
+INFO : - Path1 Queue copy to Path2 - {path2/}renamed-file1.txt
+INFO : - Path1 Queue copy to Path2 - {path2/}renamed-file2.txt
+INFO : - Path1 Queue copy to Path2 - {path2/}renamed-file3.txt
+INFO : - Path1 Queue copy to Path2 - {path2/}renamed-file4.txt
+INFO : - Path1 Queue copy to Path2 - {path2/}renamed-file5.txt
+INFO : - Path1 Do queued copies to - Path2
+INFO : {path2String}: Making map for --track-renames
+INFO : {path2String}: Finished making map for --track-renames
+INFO : renamed-file1.txt: Renamed from "file1.txt"
+INFO : renamed-file2.txt: Renamed from "file2.txt"
+INFO : renamed-file3.txt: Renamed from "file3.txt"
+INFO : renamed-file4.txt: Renamed from "file4.txt"
+INFO : renamed-file5.txt: Renamed from "file5.txt"
+INFO : There was nothing to transfer
+INFO : Updating listings
+INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}"
+INFO : Bisync successful
+
+(29) : test rename-aware max-delete should work from Path2
+(30) : copy-as {path2/}renamed-file1.txt {path2/} renamed2-file1.txt
+(31) : delete-file {path2/}renamed-file1.txt
+(32) : copy-as {path2/}renamed-file2.txt {path2/} renamed2-file2.txt
+(33) : delete-file {path2/}renamed-file2.txt
+(34) : copy-as {path2/}renamed-file3.txt {path2/} renamed2-file3.txt
+(35) : delete-file {path2/}renamed-file3.txt
+(36) : copy-as {path2/}renamed-file4.txt {path2/} renamed2-file4.txt
+(37) : delete-file {path2/}renamed-file4.txt
+(38) : copy-as {path2/}renamed-file5.txt {path2/} renamed2-file5.txt
+(39) : delete-file {path2/}renamed-file5.txt
+(40) : bisync track-renames max-delete-renames-aware
+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 : - Path2 File was deleted - renamed-file1.txt
+INFO : - Path2 File was deleted - renamed-file2.txt
+INFO : - Path2 File was deleted - renamed-file3.txt
+INFO : - Path2 File was deleted - renamed-file4.txt
+INFO : - Path2 File was deleted - renamed-file5.txt
+INFO : - Path2 File is new - renamed2-file1.txt
+INFO : - Path2 File is new - renamed2-file2.txt
+INFO : - Path2 File is new - renamed2-file3.txt
+INFO : - Path2 File is new - renamed2-file4.txt
+INFO : - Path2 File is new - renamed2-file5.txt
+INFO : Path2: 10 changes:  5 new,  0 modified,  5 deleted
+INFO : Path2: excluding 5 tracked renames from --max-delete
+INFO : Applying changes
+INFO : - Path1 Queue delete - {path1/}renamed-file1.txt
+INFO : - Path1 Queue delete - {path1/}renamed-file2.txt
+INFO : - Path1 Queue delete - {path1/}renamed-file3.txt
+INFO : - Path1 Queue delete - {path1/}renamed-file4.txt
+INFO : - Path1 Queue delete - {path1/}renamed-file5.txt
+INFO : - Path2 Queue copy to Path1 - {path1/}renamed2-file1.txt
+INFO : - Path2 Queue copy to Path1 - {path1/}renamed2-file2.txt
+INFO : - Path2 Queue copy to Path1 - {path1/}renamed2-file3.txt
+INFO : - Path2 Queue copy to Path1 - {path1/}renamed2-file4.txt
+INFO : - Path2 Queue copy to Path1 - {path1/}renamed2-file5.txt
+INFO : - Path2 Do queued copies to - Path1
+INFO : {path1String}: Making map for --track-renames
+INFO : {path1String}: Finished making map for --track-renames
+INFO : renamed2-file1.txt: Renamed from "renamed-file1.txt"
+INFO : renamed2-file2.txt: Renamed from "renamed-file2.txt"
+INFO : renamed2-file3.txt: Renamed from "renamed-file3.txt"
+INFO : renamed2-file4.txt: Renamed from "renamed-file4.txt"
+INFO : renamed2-file5.txt: Renamed from "renamed-file5.txt"
+INFO : There was nothing to transfer
+INFO : Updating listings
+INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}"
+INFO : Bisync successful
+
+(41) : test unmatched deletes should still exceed max-delete
+(42) : copy-as {path1/}renamed2-file1.txt {path1/} moved-file1.txt
+(43) : delete-file {path1/}renamed2-file1.txt
+(44) : delete-file {path1/}renamed2-file2.txt
+(45) : delete-file {path1/}renamed2-file3.txt
+(46) : delete-file {path1/}renamed2-file4.txt
+(47) : delete-file {path1/}renamed2-file5.txt
+(48) : delete-file {path1/}file6.txt
+(49) : delete-file {path1/}file7.txt
+(50) : bisync track-renames max-delete-renames-aware
+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 - file6.txt
+INFO : - Path1 File was deleted - file7.txt
+INFO : - Path1 File was deleted - renamed2-file1.txt
+INFO : - Path1 File was deleted - renamed2-file2.txt
+INFO : - Path1 File was deleted - renamed2-file3.txt
+INFO : - Path1 File was deleted - renamed2-file4.txt
+INFO : - Path1 File was deleted - renamed2-file5.txt
+INFO : - Path1 File is new - moved-file1.txt
+INFO : Path1: 8 changes:  1 new,  0 modified,  7 deleted
+INFO : Path2 checking for diffs
+INFO : Path1: excluding 1 tracked renames from --max-delete
+ERROR : Safety abort: too many deletes (>50%, 6 of 9 after excluding 1 tracked renames) on Path1 "{path1/}". Run with --force if desired.
+NOTICE: Bisync aborted. Please try again.
+Bisync error: too many deletes
+(51) : copy-listings partial-fail
+
+(52) : test force bypasses max-delete and rename-aware hash preflight
+(53) : bisync track-renames max-delete-renames-aware ignore-listing-checksum force
+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 - file6.txt
+INFO : - Path1 File was deleted - file7.txt
+INFO : - Path1 File was deleted - renamed2-file1.txt
+INFO : - Path1 File was deleted - renamed2-file2.txt
+INFO : - Path1 File was deleted - renamed2-file3.txt
+INFO : - Path1 File was deleted - renamed2-file4.txt
+INFO : - Path1 File was deleted - renamed2-file5.txt
+INFO : - Path1 File is new - moved-file1.txt
+INFO : Path1: 8 changes:  1 new,  0 modified,  7 deleted
+INFO : Path2 checking for diffs
+INFO : Applying changes
+INFO : - Path2 Queue delete - {path2/}file6.txt
+INFO : - Path2 Queue delete - {path2/}file7.txt
+INFO : - Path1 Queue copy to Path2 - {path2/}moved-file1.txt
+INFO : - Path2 Queue delete - {path2/}renamed2-file1.txt
+INFO : - Path2 Queue delete - {path2/}renamed2-file2.txt
+INFO : - Path2 Queue delete - {path2/}renamed2-file3.txt
+INFO : - Path2 Queue delete - {path2/}renamed2-file4.txt
+INFO : - Path2 Queue delete - {path2/}renamed2-file5.txt
+INFO : - Path1 Do queued copies to - Path2
+INFO : {path2String}: Making map for --track-renames
+INFO : {path2String}: Finished making map for --track-renames
+INFO : moved-file1.txt: Renamed from "renamed2-file1.txt"
+INFO : There was nothing to transfer
+INFO : Updating listings
+INFO : Validating listings for Path1 "{path1/}" vs Path2 "{path2/}"
+INFO : Bisync successful
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/initial/file1.txt b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file1.txt
new file mode 100644
index 000000000..3eca9a4b8
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file1.txt
@@ -0,0 +1 @@
+contents for file 1
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/initial/file2.txt b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file2.txt
new file mode 100644
index 000000000..a6f056142
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file2.txt
@@ -0,0 +1 @@
+contents for file 2
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/initial/file3.txt b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file3.txt
new file mode 100644
index 000000000..2cf390d27
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file3.txt
@@ -0,0 +1 @@
+contents for file 3
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/initial/file4.txt b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file4.txt
new file mode 100644
index 000000000..526e88cd2
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file4.txt
@@ -0,0 +1 @@
+contents for file 4
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/initial/file5.txt b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file5.txt
new file mode 100644
index 000000000..473262394
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file5.txt
@@ -0,0 +1 @@
+contents for file 5
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/initial/file6.txt b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file6.txt
new file mode 100644
index 000000000..9e80ef1f0
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file6.txt
@@ -0,0 +1 @@
+contents for file 6
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/initial/file7.txt b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file7.txt
new file mode 100644
index 000000000..165303c28
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file7.txt
@@ -0,0 +1 @@
+contents for file 7
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/initial/file8.txt b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file8.txt
new file mode 100644
index 000000000..7ad5ad1d1
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file8.txt
@@ -0,0 +1 @@
+contents for file 8
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/initial/file9.txt b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file9.txt
new file mode 100644
index 000000000..8bc8a2d5b
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/initial/file9.txt
@@ -0,0 +1 @@
+contents for file 9
diff --git a/cmd/bisync/testdata/test_max_delete_track_renames/scenario.txt b/cmd/bisync/testdata/test_max_delete_track_renames/scenario.txt
new file mode 100644
index 000000000..f4c840368
--- /dev/null
+++ b/cmd/bisync/testdata/test_max_delete_track_renames/scenario.txt
@@ -0,0 +1,67 @@
+test max-delete-track-renames
+# - Set up with 9 files.
+# - Rename 5 files on Path1, exceeding the default max-delete threshold.
+# - Confirm --track-renames alone retains the existing safety abort.
+# - Confirm the opt-in rename-aware check permits the tracked renames.
+
+test resync bypasses rename-aware hash preflight with ignored listing checksums
+bisync resync track-renames max-delete-renames-aware ignore-listing-checksum
+
+test rename-aware max-delete requires track-renames
+bisync max-delete-renames-aware
+copy-listings requires-track-fail
+
+test rename-aware max-delete rejects invalid track-renames strategies early
+bisync track-renames max-delete-renames-aware track-renames-strategy=banana
+copy-listings invalid-strategy-fail
+
+test rename-aware hash matching rejects ignored listing checksums
+bisync track-renames max-delete-renames-aware ignore-listing-checksum
+copy-listings ignore-hash-fail
+
+test rename >50% of Path1 files
+copy-as {path1/}file1.txt {path1/} renamed-file1.txt
+delete-file {path1/}file1.txt
+copy-as {path1/}file2.txt {path1/} renamed-file2.txt
+delete-file {path1/}file2.txt
+copy-as {path1/}file3.txt {path1/} renamed-file3.txt
+delete-file {path1/}file3.txt
+copy-as {path1/}file4.txt {path1/} renamed-file4.txt
+delete-file {path1/}file4.txt
+copy-as {path1/}file5.txt {path1/} renamed-file5.txt
+delete-file {path1/}file5.txt
+
+test track-renames alone should retain the max-delete safety abort
+bisync track-renames
+copy-listings initial-fail
+
+test rename-aware max-delete should permit tracked renames
+bisync track-renames max-delete-renames-aware
+
+test rename-aware max-delete should work from Path2
+copy-as {path2/}renamed-file1.txt {path2/} renamed2-file1.txt
+delete-file {path2/}renamed-file1.txt
+copy-as {path2/}renamed-file2.txt {path2/} renamed2-file2.txt
+delete-file {path2/}renamed-file2.txt
+copy-as {path2/}renamed-file3.txt {path2/} renamed2-file3.txt
+delete-file {path2/}renamed-file3.txt
+copy-as {path2/}renamed-file4.txt {path2/} renamed2-file4.txt
+delete-file {path2/}renamed-file4.txt
+copy-as {path2/}renamed-file5.txt {path2/} renamed2-file5.txt
+delete-file {path2/}renamed-file5.txt
+bisync track-renames max-delete-renames-aware
+
+test unmatched deletes should still exceed max-delete
+copy-as {path1/}renamed2-file1.txt {path1/} moved-file1.txt
+delete-file {path1/}renamed2-file1.txt
+delete-file {path1/}renamed2-file2.txt
+delete-file {path1/}renamed2-file3.txt
+delete-file {path1/}renamed2-file4.txt
+delete-file {path1/}renamed2-file5.txt
+delete-file {path1/}file6.txt
+delete-file {path1/}file7.txt
+bisync track-renames max-delete-renames-aware
+copy-listings partial-fail
+
+test force bypasses max-delete and rename-aware hash preflight
+bisync track-renames max-delete-renames-aware ignore-listing-checksum force
diff --git a/cmd/bisync/trackrenames.go b/cmd/bisync/trackrenames.go
new file mode 100644
index 000000000..eda67ee70
--- /dev/null
+++ b/cmd/bisync/trackrenames.go
@@ -0,0 +1,94 @@
+package bisync
+
+import (
+ "context"
+
+ "github.com/rclone/rclone/fs"
+ "github.com/rclone/rclone/fs/sync/trackrenames"
+)
+
+func (b *bisyncRun) trackRenamesPreflight() bool {
+ return b.opt.MaxDeleteRenamesAware && !b.opt.Force && !b.opt.Resync
+}
+
+func (b *bisyncRun) trackedRenameExemptions(ctx context.Context, ds1, ds2 *deltaSet) (path1, path2 int, err error) {
+ if ds1.exceedsDeletes() {
+ path1, err = b.trackedRenameExemptionsForPath(ctx, ds1, ds2, true)
+ if err != nil {
+ return 0, 0, err
+ }
+ }
+ if ds2.exceedsDeletes() {
+ path2, err = b.trackedRenameExemptionsForPath(ctx, ds2, ds1, false)
+ if err != nil {
+ return 0, 0, err
+ }
+ }
+ return path1, path2, nil
+}
+
+func (b *bisyncRun) trackedRenameExemptionsForPath(ctx context.Context, changed, other *deltaSet, path1 bool) (int, error) {
+ fsrc, fdst := b.fs1, b.fs2
+ srcListing, dstListing := b.march.ls1, b.march.ls2
+ if !path1 {
+ fsrc, fdst = b.fs2, b.fs1
+ srcListing, dstListing = b.march.ls2, b.march.ls1
+ }
+
+ hashType, modifyWindow, unsupported := trackrenames.CheckCapabilities(ctx, fsrc, fdst, b.trackRenamesStrategy)
+ if len(unsupported) > 0 {
+ for _, reason := range unsupported {
+ fs.Infof(fdst, "Not excluding tracked renames from --max-delete because %s", reason)
+ }
+ return 0, nil
+ }
+ if b.trackRenamesStrategy.UsesHash() && (srcListing.hash != hashType || dstListing.hash != hashType) {
+ fs.Infof(fdst, "Not excluding tracked renames from --max-delete because the listings do not contain the common %s hash", hashType)
+ return 0, nil
+ }
+
+ names := changed.sort()
+ var sources []trackrenames.Candidate
+ for _, name := range names {
+ if changed.deltas[name] != deltaNew || b.aliases.Alias(name) != name {
+ continue
+ }
+ if _, found := other.deltas[name]; found || dstListing.has(name) {
+ continue
+ }
+ if candidate, ok := listingCandidate(srcListing, name); ok {
+ sources = append(sources, candidate)
+ }
+ }
+ if len(sources) == 0 {
+ return 0, nil
+ }
+
+ var destinations []trackrenames.Candidate
+ for _, name := range names {
+ if changed.deltas[name] != deltaDeleted || b.aliases.Alias(name) != name {
+ continue
+ }
+ if _, found := other.deltas[name]; found || srcListing.has(name) || !dstListing.has(name) {
+ continue
+ }
+ if candidate, ok := listingCandidate(dstListing, name); ok {
+ destinations = append(destinations, candidate)
+ }
+ }
+
+ return trackrenames.CountGuaranteedMatches(b.trackRenamesStrategy, modifyWindow, sources, destinations), nil
+}
+
+func listingCandidate(listing *fileList, remote string) (trackrenames.Candidate, bool) {
+ info := listing.get(remote)
+ if info == nil || info.flags == "d" {
+ return trackrenames.Candidate{}, false
+ }
+ return trackrenames.Candidate{
+ Remote: remote,
+ Size: info.size,
+ ModTime: info.time,
+ Hash: info.hash,
+ }, true
+}
diff --git a/docs/content/bisync.md b/docs/content/bisync.md
index 0e6430321..0f7382d78 100644
--- a/docs/content/bisync.md
+++ b/docs/content/bisync.md
@@ -111,6 +111,7 @@ Optional Flags:
--force Bypass --max-delete safety check and run the sync. Consider using with --verbose
-h, --help help for bisync
--ignore-listing-checksum Do not use checksums for listings (add --ignore-checksum to additionally skip post-copy checksum checks)
+ --max-delete-renames-aware Exclude tracked renames from the --max-delete safety check (requires --track-renames)
--max-lock Duration Consider lock files older than this to be expired (default: 0 (never expire)) (minimum: 2m) (default 0s)
--no-cleanup Retain working files (useful for troubleshooting and testing).
--no-slow-hash Ignore listing checksums only on backends where they are slow
@@ -500,6 +501,23 @@ to bypass the check.
Also see the [all files changed](#all-files-changed) check.
+### --max-delete-renames-aware
+
+When `--track-renames` is in use, `--max-delete-renames-aware` can exclude
+files that are guaranteed to match as tracked renames from the deletion count.
+If the initial deletion count exceeds `--max-delete`, bisync performs a rename
+matching preflight before starting either sync direction. The run still aborts
+if the remaining unmatched deletions exceed the limit.
+
+The preflight uses the selected [`--track-renames-strategy`](/docs/#track-renames-strategy)
+and the attributes stored in the normal bisync listings. A hash strategy forces
+both listings to use a common hash and is incompatible with
+`--ignore-listing-checksum`. The option only exempts matches when the destination
+supports server-side moves or copies and the selected strategy is supported by both paths.
+It requires `--track-renames` and is disabled by default because hashing may add
+listing time. `--force` bypasses both the safety check and this preflight.
+The preflight is also disabled during `--resync`, when rename tracking is unavailable.
+
### --filters-file {#filters-file}
By using rclone filter features you can exclude file types or directory
@@ -1172,10 +1190,10 @@ is to rename it to the same name on both sides. (As of `rclone v1.64`,
a `--resync` is no longer required after doing so, as bisync will automatically
detect that Path1 and Path2 are in agreement.)
-Note that although the flag --track-renames ensures that renamed/moved files won't
-be deleted and uploaded again, they are still counted as deleted files for purposes
-of the --max-delete flag (as this check happens before the rename detection
-operation). See [this issue](https://github.com/rclone/rclone/issues/8685).
+By default, renamed or moved files are still counted as deleted files for
+purposes of `--max-delete`, because the safety check happens before rename
+detection. Use `--max-delete-renames-aware` together with `--track-renames` to
+run a rename preflight and exclude guaranteed matches from this count.
### `--fast-list` used by default
@@ -1915,6 +1933,11 @@ about *Unison* and synchronization in general.
## Changelog
+### `v1.76`
+
+- Added `--max-delete-renames-aware` to exclude guaranteed tracked renames from
+the `--max-delete` safety check when used with `--track-renames`.
+
### `v1.74.2`
- Fixed an issue causing `--conflict-loser pathname` to produce unexpected