Skip to content

Move deleted images to trash and clean metadata - #265

Merged
GreatV merged 2 commits into
PFCCLab:mainfrom
YDLuo-1:codex/fix-windows-delete-metadata
Aug 27, 2026
Merged

Move deleted images to trash and clean metadata#265
GreatV merged 2 commits into
PFCCLab:mainfrom
YDLuo-1:codex/fix-windows-delete-metadata

Conversation

@YDLuo-1

@YDLuo-1 YDLuo-1 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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 wrong fileStatedict key and only changed PPlabel in memory. fileState.txt, Label.txt, and Cache.cach could therefore retain references to a missing image, and Cache.cach could restore that stale entry on the next launch.

Changes

  • move files to the recycle bin on Windows with the standard-library SHFileOperationW API
  • use argument lists for Linux trash invocation and keep the existing Finder behavior on macOS
  • stop without changing metadata when moving the file to trash fails
  • remove the normalized image key from fileStatedict, PPlabel, and Cachelabel
  • persist all three metadata files before refreshing the image list

No additional dependency is introduced.

Verification

  • real Windows temporary-file check confirmed that the file is removed through the recycle-bin operation
  • mock regression check confirmed successful deletion cleans and saves all three metadata stores
  • mock failure check confirmed metadata remains unchanged when the file cannot be moved
  • python -m py_compile PPOCRLabel.py
  • git diff --check

@YDLuo-1
YDLuo-1 force-pushed the codex/fix-windows-delete-metadata branch from 8353e92 to ed9432a Compare August 27, 2026 01:56
@GreatV
GreatV requested a lite review from Copilot August 27, 2026 02:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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, Linux trash, macOS Finder via osascript).
  • Stops deletion flow without mutating metadata if moving to trash fails.
  • Removes the deleted image’s normalized key from fileStatedict, PPlabel, and Cachelabel, 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.

Comment thread PPOCRLabel.py

@GreatV GreatV left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@GreatV
GreatV merged commit 6a9f98c into PFCCLab:main Aug 27, 2026
1 check 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.

3 participants