From 41b8996b524ef4d9cfb8199ddbfbb7d1b3d32cd1 Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 3 Aug 2019 15:26:25 -0700 Subject: [PATCH] Improved rsync handling just a bit --- .gitignore | 1 + backup-diff.py | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 63a1ee6..d436cd6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea +tests diff --git a/backup-diff.py b/backup-diff.py index 11bc9ef..3f913b6 100755 --- a/backup-diff.py +++ b/backup-diff.py @@ -280,14 +280,17 @@ class BackupDiff: # Missing from backup if change_type_character == "<": entry.set_is_missing_from_backup() - - # Missing from source + # Missing from ... backup? (confusing symbolstuffs) elif change_type_character == ">": - entry.set_is_missing_from_source() + entry.set_is_missing_from_backup() # Local change is occurring elif change_type_character == "c": - entry.set_is_unknown("Rsync says a local change is occurring") + entry.set_is_missing_from_backup() + + # Different attributes + elif different_any_attribute: + entry.set_is_different_attributes() # Item is a hard link elif change_type_character == "h": @@ -699,6 +702,10 @@ class BackupDiff: "label": "Items with different file sizes", "entries": [] }, + "different_attributes": { + "label": "Items with different attributes", + "entries": [] + }, "unknown": { "label": "Differences of an unknown type", "entries": [] @@ -739,6 +746,11 @@ class BackupDiff: for entry in self.__difference_entries: if entry.get_is_different_sizes(): report["size_difference"]["entries"].append(entry) + + # Different attributes + for entry in self.__difference_entries: + if entry.get_is_different_attributes(): + report["different_attributes"]["entries"].append(entry) # Differences of an unknown nature for entry in self.__difference_entries: @@ -780,6 +792,7 @@ class BackupDiff: "missing_from_source", "newer_source", "missing_from_backup", "newer_backup", "size_difference", + "different_attributes", "unknown" ] @@ -829,6 +842,7 @@ class DifferenceEntry: self.CONST_TYPE_SOURCE_IS_NEWER = "source_is_newer" self.CONST_TYPE_BACKUP_IS_NEWER = "backup_is_newer" self.CONST_TYPE_DIFFERENT_SIZES = "different_sizes" + self.CONST_TYPE_DIFFERENT_ATTRIBUTES = "different_attributes" self.CONST_TYPE_UNKNOWN = "unknown" if item: @@ -933,6 +947,13 @@ class DifferenceEntry: def get_is_different_sizes(self): return self.__type == self.CONST_TYPE_DIFFERENT_SIZES + def set_is_different_attributes(self, message=None): + self.__type = self.CONST_TYPE_DIFFERENT_ATTRIBUTES + self.__message = message + + def get_is_different_attributes(self): + return self.__type == self.CONST_TYPE_DIFFERENT_ATTRIBUTES + def set_is_unknown(self, message): self.__type = self.CONST_TYPE_UNKNOWN self.__message = message