mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Print files that are *not* deleted by cleanup
These are files that are not present on the remote source any more, but still present locally. They also show up in the report.
This commit is contained in:
parent
a879c6ab6e
commit
adb5d4ade3
@ -493,6 +493,9 @@ class OutputDirectory:
|
|||||||
self._report.delete_file(pure)
|
self._report.delete_file(pure)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
log.status(f"[bold bright_magenta]Not deleted[/] {escape(fmt_path(pure))}")
|
||||||
|
self._report.not_delete_file(pure)
|
||||||
|
|
||||||
def load_prev_report(self) -> None:
|
def load_prev_report(self) -> None:
|
||||||
log.explain_topic(f"Loading previous report from {fmt_real_path(self._report_path)}")
|
log.explain_topic(f"Loading previous report from {fmt_real_path(self._report_path)}")
|
||||||
|
@ -136,6 +136,9 @@ class Pferd:
|
|||||||
for path in sorted(crawler.report.deleted_files):
|
for path in sorted(crawler.report.deleted_files):
|
||||||
something_changed = True
|
something_changed = True
|
||||||
log.report(f" [bold bright_magenta]Deleted[/] {fmt_path(path)}")
|
log.report(f" [bold bright_magenta]Deleted[/] {fmt_path(path)}")
|
||||||
|
for path in sorted(crawler.report.not_deleted_files):
|
||||||
|
something_changed = True
|
||||||
|
log.report(f" [bold bright_magenta]Not deleted[/] {fmt_path(path)}")
|
||||||
|
|
||||||
if not something_changed:
|
if not something_changed:
|
||||||
log.report(" Nothing changed")
|
log.report(" Nothing changed")
|
||||||
|
@ -56,6 +56,7 @@ class Report:
|
|||||||
self.added_files: Set[PurePath] = set()
|
self.added_files: Set[PurePath] = set()
|
||||||
self.changed_files: Set[PurePath] = set()
|
self.changed_files: Set[PurePath] = set()
|
||||||
self.deleted_files: Set[PurePath] = set()
|
self.deleted_files: Set[PurePath] = set()
|
||||||
|
self.not_deleted_files: Set[PurePath] = set()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_list_of_strs(data: Dict[str, Any], key: str) -> List[str]:
|
def _get_list_of_strs(data: Dict[str, Any], key: str) -> List[str]:
|
||||||
@ -93,6 +94,8 @@ class Report:
|
|||||||
self.change_file(PurePath(elem))
|
self.change_file(PurePath(elem))
|
||||||
for elem in self._get_list_of_strs(data, "deleted"):
|
for elem in self._get_list_of_strs(data, "deleted"):
|
||||||
self.delete_file(PurePath(elem))
|
self.delete_file(PurePath(elem))
|
||||||
|
for elem in self._get_list_of_strs(data, "not_deleted"):
|
||||||
|
self.not_delete_file(PurePath(elem))
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@ -107,6 +110,7 @@ class Report:
|
|||||||
"added": [str(path) for path in sorted(self.added_files)],
|
"added": [str(path) for path in sorted(self.added_files)],
|
||||||
"changed": [str(path) for path in sorted(self.changed_files)],
|
"changed": [str(path) for path in sorted(self.changed_files)],
|
||||||
"deleted": [str(path) for path in sorted(self.deleted_files)],
|
"deleted": [str(path) for path in sorted(self.deleted_files)],
|
||||||
|
"not_deleted": [str(path) for path in sorted(self.not_deleted_files)],
|
||||||
}
|
}
|
||||||
|
|
||||||
with open(path, "w") as f:
|
with open(path, "w") as f:
|
||||||
@ -163,3 +167,10 @@ class Report:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
self.deleted_files.add(path)
|
self.deleted_files.add(path)
|
||||||
|
|
||||||
|
def not_delete_file(self, path: PurePath) -> None:
|
||||||
|
"""
|
||||||
|
Unlike mark(), this function accepts any paths.
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.not_deleted_files.add(path)
|
||||||
|
Loading…
Reference in New Issue
Block a user