This commit is contained in:
MisterPine 2026-01-08 23:36:52 +00:00 committed by GitHub
commit 0dbf9e27f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View file

@ -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)}")

View file

@ -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.