fix: improve conflict detection by tracking previous file hash (fixes #10349) (#10351)

This adds a new field to the file information we keep, the "previous
blocks hash". This is the hash of the file contents as it was in its
previous incarnation. That is, every scan that updates the blocks hash
will move the current hash to the "previous" field.

This enables an addition to the conflict detection algorithm: if the
file to be synced is in conflict with the current file on disk
(version-counter wise), but it indicates that it was based on the
precise contents we have (new.prevBlocksHash == current.blocksHash),
then it's not really a conflict.

Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
Jakob Borg
2025-09-13 16:16:28 +02:00
committed by GitHub
parent 1b0eaa093a
commit d037681fd1
8 changed files with 447 additions and 421 deletions
+2 -1
View File
@@ -113,6 +113,7 @@ message FileInfo {
repeated BlockInfo blocks = 16;
bytes symlink_target = 17;
bytes blocks_hash = 18;
bytes previous_blocks_hash = 20;
bytes encrypted = 19;
FileInfoType type = 2;
uint32 permissions = 4;
@@ -127,7 +128,7 @@ message FileInfo {
uint32 local_flags = 1000;
// The version_hash is an implementation detail and not part of the wire
// format.
// format. It is used in the old database format.
bytes version_hash = 1001;
// The time when the inode was last changed (i.e., permissions, xattrs
+1
View File
@@ -17,6 +17,7 @@ message FileInfoTruncated {
reserved 16; // blocks
bytes symlink_target = 17;
bytes blocks_hash = 18;
bytes previous_blocks_hash = 20;
bytes encrypted = 19;
bep.FileInfoType type = 2;
uint32 permissions = 4;