Improved rsync handling just a bit

This commit is contained in:
Mike 2019-08-03 15:26:25 -07:00
parent 8fed1656b4
commit 41b8996b52
2 changed files with 26 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.idea .idea
tests

View File

@ -280,14 +280,17 @@ class BackupDiff:
# Missing from backup # Missing from backup
if change_type_character == "<": if change_type_character == "<":
entry.set_is_missing_from_backup() entry.set_is_missing_from_backup()
# Missing from ... backup? (confusing symbolstuffs)
# Missing from source
elif change_type_character == ">": elif change_type_character == ">":
entry.set_is_missing_from_source() entry.set_is_missing_from_backup()
# Local change is occurring # Local change is occurring
elif change_type_character == "c": 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 # Item is a hard link
elif change_type_character == "h": elif change_type_character == "h":
@ -699,6 +702,10 @@ class BackupDiff:
"label": "Items with different file sizes", "label": "Items with different file sizes",
"entries": [] "entries": []
}, },
"different_attributes": {
"label": "Items with different attributes",
"entries": []
},
"unknown": { "unknown": {
"label": "Differences of an unknown type", "label": "Differences of an unknown type",
"entries": [] "entries": []
@ -740,6 +747,11 @@ class BackupDiff:
if entry.get_is_different_sizes(): if entry.get_is_different_sizes():
report["size_difference"]["entries"].append(entry) 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 # Differences of an unknown nature
for entry in self.__difference_entries: for entry in self.__difference_entries:
if entry.get_is_unknown(): if entry.get_is_unknown():
@ -780,6 +792,7 @@ class BackupDiff:
"missing_from_source", "newer_source", "missing_from_source", "newer_source",
"missing_from_backup", "newer_backup", "missing_from_backup", "newer_backup",
"size_difference", "size_difference",
"different_attributes",
"unknown" "unknown"
] ]
@ -829,6 +842,7 @@ class DifferenceEntry:
self.CONST_TYPE_SOURCE_IS_NEWER = "source_is_newer" self.CONST_TYPE_SOURCE_IS_NEWER = "source_is_newer"
self.CONST_TYPE_BACKUP_IS_NEWER = "backup_is_newer" self.CONST_TYPE_BACKUP_IS_NEWER = "backup_is_newer"
self.CONST_TYPE_DIFFERENT_SIZES = "different_sizes" self.CONST_TYPE_DIFFERENT_SIZES = "different_sizes"
self.CONST_TYPE_DIFFERENT_ATTRIBUTES = "different_attributes"
self.CONST_TYPE_UNKNOWN = "unknown" self.CONST_TYPE_UNKNOWN = "unknown"
if item: if item:
@ -933,6 +947,13 @@ class DifferenceEntry:
def get_is_different_sizes(self): def get_is_different_sizes(self):
return self.__type == self.CONST_TYPE_DIFFERENT_SIZES 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): def set_is_unknown(self, message):
self.__type = self.CONST_TYPE_UNKNOWN self.__type = self.CONST_TYPE_UNKNOWN
self.__message = message self.__message = message