mirror of
https://github.com/Garmelon/PFERD.git
synced 2026-04-12 15:35: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)
|
await self._cleanup_file(path, pure)
|
||||||
|
|
||||||
async def _cleanup_dir(self, path: Path, pure: PurePath, delete_self: bool = True) -> None:
|
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()):
|
for child in sorted(path.iterdir()):
|
||||||
pure_child = pure / child.name
|
pure_child = pure / child.name
|
||||||
await self._cleanup(child, pure_child)
|
await self._cleanup(child, pure_child)
|
||||||
|
|
@ -525,8 +529,11 @@ class OutputDirectory:
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
log.not_deleted("[bold bright_magenta]", "Not deleted", fmt_path(pure))
|
self._report_not_deleted(pure)
|
||||||
self._report.not_delete_file(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:
|
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)}")
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,9 @@ class Report:
|
||||||
def is_marked(self, path: PurePath) -> bool:
|
def is_marked(self, path: PurePath) -> bool:
|
||||||
return path in self.marked
|
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:
|
def add_file(self, path: PurePath) -> None:
|
||||||
"""
|
"""
|
||||||
Unlike mark(), this function accepts any paths.
|
Unlike mark(), this function accepts any paths.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue