Move deleted images to trash and clean metadata - #265
Merged
Conversation
YDLuo-1
force-pushed
the
codex/fix-windows-delete-metadata
branch
from
August 27, 2026 01:56
8353e92 to
ed9432a
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes cross-platform image deletion so that “delete” moves the image to the OS trash/recycle bin (instead of permanently removing it on Windows) and ensures related metadata stores are cleaned and persisted consistently to avoid stale entries on restart.
Changes:
- Adds a cross-platform
moveFileToTrash()helper (Windows SHFileOperationW, Linuxtrash, macOS Finder viaosascript). - Stops deletion flow without mutating metadata if moving to trash fails.
- Removes the deleted image’s normalized key from
fileStatedict,PPlabel, andCachelabel, then saves all three stores before refreshing the image list.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The delete confirmation says that an image will be moved to the recycle bin, but Windows used
os.remove, which permanently deleted it. After deletion, the code also removed the wrongfileStatedictkey and only changedPPlabelin memory.fileState.txt,Label.txt, andCache.cachcould therefore retain references to a missing image, andCache.cachcould restore that stale entry on the next launch.Changes
SHFileOperationWAPIfileStatedict,PPlabel, andCachelabelNo additional dependency is introduced.
Verification
python -m py_compile PPOCRLabel.pygit diff --check