-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Improve attachments deletion #35103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Improve attachments deletion #35103
Conversation
026b762
to
f3d0e51
Compare
4ae54c8
to
97556a8
Compare
Change my opinion: it looks wrong. |
I’ve pushed some new commits. Could you please review them again and let me know if there are any concerns? |
The design is wrong and not worth to review. If your plan is "the enum can be reused for other storages in the future", you need a separate table like "storage_file_deletion (storage_type, storage_path)", but not keep patching other tables. |
…torage could reuse the deletion infrastructure
@lafriks @wxiaoguang I reimplemented it and use a standalone table |
Refactor attachment deletion logic
The attachment of comment deletion process has been moved from the
AfterDelete
hook to the service layer. This change avoids scenarios where files are deleted while the database transaction is later rolled back. The new implementation introduces a two-stage deletion process via adding a new table namedstorage_path_deletion
. All files need to be deleted will be added here and then a cron job will check it and delete the files. If file deletion fails repeatedly, a system notice will be issued to alert administrators.This will also improve performance when deleting a release with many files.
Removed unused functions
DeleteAttachmentsByIssue
andDeleteAttachmentsByComment
are removed because only tests need them.