mirror of
https://github.com/Garmelon/PFERD.git
synced 2026-04-12 23:45:05 +02:00
Merge 6dae86df7d into e246053de2
This commit is contained in:
commit
0dbf9e27f4
2 changed files with 12 additions and 2 deletions
|
|
@ -505,6 +505,10 @@ class OutputDirectory:
|
|||
await self._cleanup_file(path, pure)
|
||||
|
||||
async def _cleanup_dir(self, path: Path, pure: PurePath, delete_self: bool = True) -> None:
|
||||
if self._on_conflict in {OnConflict.NO_DELETE, OnConflict.NO_DELETE_PROMPT_OVERWRITE} and not self.report.contains_marked(pure):
|
||||
self._report_not_deleted(pure)
|
||||
return
|
||||
|
||||
for child in sorted(path.iterdir()):
|
||||
pure_child = pure / child.name
|
||||
await self._cleanup(child, pure_child)
|
||||
|
|
@ -525,8 +529,11 @@ class OutputDirectory:
|
|||
except OSError:
|
||||
pass
|
||||
else:
|
||||
log.not_deleted("[bold bright_magenta]", "Not deleted", fmt_path(pure))
|
||||
self._report.not_delete_file(pure)
|
||||
self._report_not_deleted(pure)
|
||||
|
||||
def _report_not_deleted(self, path: PurePath) -> None:
|
||||
log.not_deleted("[bold bright_magenta]", "Not deleted", fmt_path(path))
|
||||
self._report.not_delete_file(path)
|
||||
|
||||
def load_prev_report(self) -> None:
|
||||
log.explain_topic(f"Loading previous report from {fmt_real_path(self._report_path)}")
|
||||
|
|
|
|||
|
|
@ -176,6 +176,9 @@ class Report:
|
|||
def is_marked(self, path: PurePath) -> bool:
|
||||
return path in self.marked
|
||||
|
||||
def contains_marked(self, path: PurePath) -> bool:
|
||||
return any(marked_file.is_relative_to(path) for marked_file in self.marked)
|
||||
|
||||
def add_file(self, path: PurePath) -> None:
|
||||
"""
|
||||
Unlike mark(), this function accepts any paths.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue