[pbs-devel] [PATCH proxmox-backup 1/1] fix #3828: proxmox_backup_debug: Introduce `diff archive` subcommand.
Wolfgang Bumiller
w.bumiller at proxmox.com
Thu Oct 27 15:39:29 CEST 2022
On Thu, Oct 27, 2022 at 02:28:06PM +0200, Lukas Wagner wrote:
> +async fn compare_file(file_a: &FileEntry, file_b: &FileEntry) -> bool {
> + if file_a.metadata() != file_b.metadata() {
> + // Check if mtime, permissions, ACLs, etc. have changed - if they have changed, we consider
> + // the file as modified.
> + return false;
> + }
> +
> + match (file_a.kind(), file_b.kind()) {
> + (EntryKind::Symlink(a), EntryKind::Symlink(b)) => {
> + // Check whether the link target has changed.
> + a.as_os_str() == b.as_os_str()
> + }
> + (EntryKind::Hardlink(a), EntryKind::Hardlink(b)) => {
> + // Check whether the link target has changed.
> + a.as_os_str() == b.as_os_str()
> + }
> + (EntryKind::Device(a), EntryKind::Device(b)) => a.major == b.major && a.minor == b.minor,
> + (EntryKind::Socket, EntryKind::Socket) => true,
> + (EntryKind::Fifo, EntryKind::Fifo) => true,
> + (EntryKind::GoodbyeTable, EntryKind::GoodbyeTable) => {
> + // For some reason, .kind() returns GoodbyeTable for FIFOs/Sockets - is this a bug?
Interesting. Fixed & updated the tests for this.
This only happens in the random accessor as it never reached the
FILENAME/GOODBYE header which would normally take care of updating the
kind to reflect the metadata.
Lingering bugs like this are one of the things that make me want to
replace most of the internals with language-supported generators soon...
> + // This match arm can be removed if this is fixed.
> + true
> + }
> + (EntryKind::File { size: size_a, .. }, EntryKind::File { size: size_b, .. }) => {
> + // At this point we know that all metadata including mtime is
> + // the same. To speed things up, we consider the files as equal if they also have
> + // the same size.
> + // If one were completely paranoid, one could compare the actual file contents,
> + // but this decreases performance drastically.
> + size_a == size_b
> + }
> + (EntryKind::Directory, EntryKind::Directory) => true,
> + (_, _) => false, // Kind has changed, so we of course consider it modified.
> + }
> +}
More information about the pbs-devel
mailing list