Skip to content

Record partial deletion when archive is trashed but original removal fails - #18

Merged
smurftyy merged 1 commit into
smurftyy:mainfrom
olanihundaniel0-star:fix-issue-14
Oct 4, 2026
Merged

smurftyy merged 1 commit into
smurftyy:mainfrom
olanihundaniel0-star:fix-issue-14

Conversation

@olanihundaniel0-star

Copy link
Copy Markdown
Contributor

Fixes #14.

Problem

In the compress-before-trash flow, if send2trash(archive) succeeded but shutil.rmtree(source) failed, the item landed in result.failed with no metadata written. The archive was genuinely in trash, but history and doctor had no way to know, so it stayed invisible.

Changes

  • Added distinct PartialDeletion outcome on DeleteResult (partial, partial_count), separate from deleted / failed.
  • Added OriginalCleanupError(OSError) carrying the trashed DeletionArchive through the rmtree failure.
  • delete_items now routes that case to partial and preserves the archive for recording.
  • Metadata schema v5 → v6: new status field (deleted / partial, defaults to deleted for legacy records). record_successes writes partials under the same run_id.
  • Text output renders partials with ⚠ + N partial: archive in trash, original still on disk.
  • doctor treats partial records as valid (flags only unknown status as corrupt).
  • Updated test_delete_items_surfaces_error_when_original_removal_fails_after_trash plus version assertions, added a CHANGELOG [Unreleased] note.

Verification

ruff check .
ruff format --check .
mypy
pytest
pytest --cov=devklean --cov-report=term-missing

270 passed.

Copilot AI lite review requested due to automatic review settings September 26, 2026 18:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@smurftyy

smurftyy commented Oct 4, 2026

Copy link
Copy Markdown
Owner

LGTM

@smurftyy
smurftyy merged commit a3825f8 into smurftyy:main Oct 4, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metadata record isn't written when trash succeeds but original removal fails

3 participants