Add bitrot detection to "diff" command

This introduces a new modifier to the output of the diff command. It
appears whenever two files being compared only differ in their content
but not in their metadata. As far as we know, under normal
circumstances, this should only ever happen if some kind of bitrot has
happened in the source file. The prerequisite for this detection to work
is that the right-side snapshot of the comparison has been created with
"backup --force".
This commit is contained in:
Daniel Danner authored and Michael Eischer committed 2024-01-06 20:12:47 +01:00
1 parent 634e2a46d9
commit a7dc18e697
3 files changed
+22 -1

No files matched your search

+9
View File
@@ -27,6 +27,7 @@ directory:
* U The metadata (access mode, timestamps, ...) for the item was updated
* M The file's content was modified
* T The type was changed, e.g. a file was made a symlink
* ? Bitrot detected: The file's content has changed but all metadata is the same
To only compare files in specific subfolders, you can use the
"<snapshotID>:<subfolder>" syntax, where "subfolder" is a path within the
@@ -272,6 +273,14 @@ func (c *Comparer) diffTree(ctx context.Context, stats *DiffStatsContainer, pref
!reflect.DeepEqual(node1.Content, node2.Content) {
mod += "M"
stats.ChangedFiles++
node1NilContent := node1
node2NilContent := node2
node1NilContent.Content = nil
node2NilContent.Content = nil
if node1NilContent.Equals(*node2NilContent) {
mod += "?"
}
} else if c.opts.ShowMetadata && !node1.Equals(*node2) {
mod += "U"
}