Skip to content

fix: enhance file and trash services with metadata validation#12529

Merged
wanghe-fit2cloud merged 3 commits into1Panel-dev:dev-v2from
HynoR:feat/rcy
Apr 20, 2026
Merged

fix: enhance file and trash services with metadata validation#12529
wanghe-fit2cloud merged 3 commits into1Panel-dev:dev-v2from
HynoR:feat/rcy

Conversation

@HynoR
Copy link
Copy Markdown
Contributor

@HynoR HynoR commented Apr 20, 2026

What this PR does / why we need it?

#12525

Summary of your change

This pull request introduces a significant refactor and enhancement to the recycle bin implementation, transitioning from a legacy, monolithic file structure to a more robust design using separate files and info subdirectories with dedicated metadata files. It improves the management, recovery, and cleanup of deleted files, adds better error handling and logging, and refactors file name validation for consistency.

Recycle Bin Architecture Improvements

  • The recycle bin now organizes deleted files into .1panel_clash/files for file content and .1panel_clash/info for metadata, using a new .trashinfo metadata format for each entry. This design makes it easier to manage, recover, and clean up deleted files. [1] [2]
  • New helper functions (ensureTrashDirs, writeTrashInfo, readTrashInfo, etc.) handle the creation and management of these subdirectories and metadata files, improving code maintainability.

File Deletion and Recovery Enhancements

  • When deleting or recovering files, the system now consistently cleans up associated .trashinfo metadata, reducing orphaned metadata and potential inconsistencies. [1] [2] [3]
  • The Create and Reduce operations for the recycle bin are updated to use the new metadata format, improving the accuracy of recovery and metadata tracking. [1] [2]

Improved Listing and Paging of Deleted Files

  • The recycle bin listing (Page) now aggregates entries from both the new structure and legacy files for backward compatibility, and prunes orphaned metadata files automatically. [1] [2]

Error Handling and Logging

  • Enhanced error handling and logging throughout the recycle bin operations, including warnings for failed cleanup, error rollbacks, and panic recovery in background deletion tasks. [1] [2] [3]

Code Refactoring and Validation Consistency

  • Refactored file name validation logic into a reusable hasInvalidFileName function for consistency across file creation and renaming operations. [1] [2]

These changes collectively make the recycle bin more reliable, maintainable, and user-friendly, with better support for recovery and system integrity.#

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented Apr 20, 2026

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented Apr 20, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign wanghe-fit2cloud for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@HynoR HynoR marked this pull request as ready for review April 20, 2026 04:40
@f2c-ci-robot f2c-ci-robot Bot requested a review from zhengkunwang223 April 20, 2026 04:40
@lan-yonghui
Copy link
Copy Markdown
Member

/lgtm

@f2c-ci-robot f2c-ci-robot Bot added the lgtm label Apr 20, 2026
@wanghe-fit2cloud wanghe-fit2cloud merged commit abd1581 into 1Panel-dev:dev-v2 Apr 20, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants