Introduce "relocated" state to unify and replace "copied/removed" logic

This commit is contained in:
Andrea Mazzoleni 2026-03-14 17:48:30 +01:00
parent 189029749e
commit c449864fc7
9 changed files with 167 additions and 64 deletions

View file

@ -793,15 +793,23 @@ They are identified by having the same name, size, timestamp,
and inode, but a different directory.
.HP 4
.I copied
Files copied on the same or a different disk. Note that if
they are truly moved to a different disk, they will also be
counted in \`removed\`.
They are identified by having the same name, size, and
timestamp. If the sub\-second timestamp is zero,
the full path must match, not just the name.
Files copied on the same or a different disk where the
original file still exists. They are identified by having
the same name, size, and timestamp. If the sub\-second
timestamp is zero, the full path must match to be
identified, not just the name.
.HP 4
.I relocated
Files moved on the same or a different disk where
the original has disappeared. They are identified by
having the same name, size, and timestamp. If the
sub\-second timestamp is zero, the full path must match
to be identified. Unlike \'moved\' files on the same disk,
relocated files have a different inode.
.HP 4
.I restored
Files with a different inode but matching name, size, and timestamp.
Files with a different inode but matching directory,
name, size, and timestamp.
These are usually files restored after being deleted.
.PD
.RE

View file

@ -505,13 +505,19 @@ Commands
moved - Files moved to a different directory on the same disk.
They are identified by having the same name, size, timestamp,
and inode, but a different directory.
copied - Files copied on the same or a different disk. Note that if
they are truly moved to a different disk, they will also be
counted in `removed`.
They are identified by having the same name, size, and
timestamp. If the sub-second timestamp is zero,
the full path must match, not just the name.
restored - Files with a different inode but matching name, size, and timestamp.
copied - Files copied on the same or a different disk where the
original file still exists. They are identified by having
the same name, size, and timestamp. If the sub-second
timestamp is zero, the full path must match to be
identified, not just the name.
relocated - Files moved on the same or a different disk where
the original has disappeared. They are identified by
having the same name, size, and timestamp. If the
sub-second timestamp is zero, the full path must match
to be identified. Unlike 'moved' files on the same disk,
relocated files have a different inode.
restored - Files with a different inode but matching directory,
name, size, and timestamp.
These are usually files restored after being deleted.
If a `sync` is required, the process return code is 2, instead of the

View file

@ -541,13 +541,19 @@ presented, grouped by:
moved - Files moved to a different directory on the same disk.
They are identified by having the same name, size, timestamp,
and inode, but a different directory.
copied - Files copied on the same or a different disk. Note that if
they are truly moved to a different disk, they will also be
counted in `removed`.
They are identified by having the same name, size, and
timestamp. If the sub-second timestamp is zero,
the full path must match, not just the name.
restored - Files with a different inode but matching name, size, and timestamp.
copied - Files copied on the same or a different disk where the
original file still exists. They are identified by having
the same name, size, and timestamp. If the sub-second
timestamp is zero, the full path must match to be
identified, not just the name.
relocated - Files moved on the same or a different disk where
the original has disappeared. They are identified by
having the same name, size, and timestamp. If the
sub-second timestamp is zero, the full path must match
to be identified. Unlike 'moved' files on the same disk,
relocated files have a different inode.
restored - Files with a different inode but matching directory,
name, size, and timestamp.
These are usually files restored after being deleted.
If a `sync` is required, the process return code is 2, instead of the

View file

@ -431,8 +431,9 @@ A file or link has been updated (size, timestamp, or link target changed).
This item will have its content data blocks re\-hashed in a \`sync\`.
.TP
.B scan:move:<disk_name>:<old_path>:<new_path>
A file was moved on the same disk. This is an efficient operation
that only updates the path metadata without re\-hashing blocks.
A file was moved to a different directory on the same disk.
This is an efficient operation that only updates the path
metadata without rehashing blocks.
.RS 4
.PD 0
.HP 4
@ -445,9 +446,11 @@ The new path to the file (escaped).
.RE
.TP
.B scan:copy:<disk_name>:<path>:<source_disk>:<source_path>
A new file was found to be a copy of a file from another disk.
This is detected by matching file size and timestamp, and is an
efficient operation that avoids re\-hashing all blocks.
A new file was found to be a copy of a file on the same or
any other disk.
This is detected by matching the file name,
size, and timestamp, and is an efficient operation that avoids
rehashing all blocks.
.RS 4
.PD 0
.HP 4
@ -459,9 +462,16 @@ The original file\'s location (escaped).
.PD
.RE
.TP
.B scan:relocate:<disk_name>:<path>:<source_disk>:<source_path>
Like \`copy\`, but the original file has disappeared.
The difference between \`move\` and \`relocate\` on the same
disk is that \`move\` is only used if the inode remains
the same.
.TP
.B scan:restore:<disk_name>:<path>
A file\'s inode has changed but not its date\-time and size,
which suggests the file may be restored from backup.
A file\'s inode has changed but not its directory, name,
timestamp and size, which suggests the file may be restored
from backup.
The file won\'t be re\-hashed in \`sync\` as its precomputed hash
is assumed to be correct.
.PP
@ -491,6 +501,10 @@ retaining the same inode (uint).
Total number of new files created by copying an existing
protected file to a new path (uint).
.TP
.B summary:relocated:<count>
Total number of new files created by relocating an existing
protected file to a new path (uint).
.TP
.B summary:restored:<count>
Total number of new files matching a parity entry by
name/time/size but with a new inode (uint).

View file

@ -287,23 +287,33 @@ Scan Tags
This item will have its content data blocks re-hashed in a `sync`.
=scan:move:<disk_name>:<old_path>:<new_path>
A file was moved on the same disk. This is an efficient operation
that only updates the path metadata without re-hashing blocks.
A file was moved to a different directory on the same disk.
This is an efficient operation that only updates the path
metadata without rehashing blocks.
<old_path> - The old path to the file (escaped).
<new_path> - The new path to the file (escaped).
=scan:copy:<disk_name>:<path>:<source_disk>:<source_path>
A new file was found to be a copy of a file from another disk.
This is detected by matching file size and timestamp, and is an
efficient operation that avoids re-hashing all blocks.
A new file was found to be a copy of a file on the same or
any other disk.
This is detected by matching the file name,
size, and timestamp, and is an efficient operation that avoids
rehashing all blocks.
<source_disk> - The original file's disk.
<source_path> - The original file's location (escaped).
=scan:relocate:<disk_name>:<path>:<source_disk>:<source_path>
Like `copy`, but the original file has disappeared.
The difference between `move` and `relocate` on the same
disk is that `move` is only used if the inode remains
the same.
=scan:restore:<disk_name>:<path>
A file's inode has changed but not its date-time and size,
which suggests the file may be restored from backup.
A file's inode has changed but not its directory, name,
timestamp and size, which suggests the file may be restored
from backup.
The file won't be re-hashed in `sync` as its precomputed hash
is assumed to be correct.
@ -333,6 +343,10 @@ Scan Tags
Total number of new files created by copying an existing
protected file to a new path (uint).
=summary:relocated:<count>
Total number of new files created by relocating an existing
protected file to a new path (uint).
=summary:restored:<count>
Total number of new files matching a parity entry by
name/time/size but with a new inode (uint).

View file

@ -303,23 +303,33 @@ content file. They are output for every discovered change.
This item will have its content data blocks re-hashed in a `sync`.
scan:move:<disk_name>:<old_path>:<new_path>
A file was moved on the same disk. This is an efficient operation
that only updates the path metadata without re-hashing blocks.
A file was moved to a different directory on the same disk.
This is an efficient operation that only updates the path
metadata without rehashing blocks.
<old_path> - The old path to the file (escaped).
<new_path> - The new path to the file (escaped).
scan:copy:<disk_name>:<path>:<source_disk>:<source_path>
A new file was found to be a copy of a file from another disk.
This is detected by matching file size and timestamp, and is an
efficient operation that avoids re-hashing all blocks.
A new file was found to be a copy of a file on the same or
any other disk.
This is detected by matching the file name,
size, and timestamp, and is an efficient operation that avoids
rehashing all blocks.
<source_disk> - The original file's disk.
<source_path> - The original file's location (escaped).
scan:relocate:<disk_name>:<path>:<source_disk>:<source_path>
Like `copy`, but the original file has disappeared.
The difference between `move` and `relocate` on the same
disk is that `move` is only used if the inode remains
the same.
scan:restore:<disk_name>:<path>
A file's inode has changed but not its date-time and size,
which suggests the file may be restored from backup.
A file's inode has changed but not its directory, name,
timestamp and size, which suggests the file may be restored
from backup.
The file won't be re-hashed in `sync` as its precomputed hash
is assumed to be correct.
@ -349,6 +359,10 @@ These tags provide a final count of all detected changes.
Total number of new files created by copying an existing
protected file to a new path (uint).
summary:relocated:<count>
Total number of new files created by relocating an existing
protected file to a new path (uint).
summary:restored:<count>
Total number of new files matching a parity entry by
name/time/size but with a new inode (uint).