From 3549635243d77679871fa6dd54b1d17b9ac5cb7b Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 6 Jan 2024 20:07:46 +0100 Subject: [PATCH] diff: copy nodes before modifying them for bitrot detection --- cmd/restic/cmd_diff.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/restic/cmd_diff.go b/cmd/restic/cmd_diff.go index 329d11d02..aafc558b8 100644 --- a/cmd/restic/cmd_diff.go +++ b/cmd/restic/cmd_diff.go @@ -274,11 +274,13 @@ func (c *Comparer) diffTree(ctx context.Context, stats *DiffStatsContainer, pref mod += "M" stats.ChangedFiles++ - node1NilContent := node1 - node2NilContent := node2 + node1NilContent := *node1 + node2NilContent := *node2 node1NilContent.Content = nil node2NilContent.Content = nil - if node1NilContent.Equals(*node2NilContent) { + // the bitrot detection may not work if `backup --ignore-inode` or `--ignore-ctime` were used + if node1NilContent.Equals(node2NilContent) { + // probable bitrot detected mod += "?" } } else if c.opts.ShowMetadata && !node1.Equals(*node2) {