Skip to content

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

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

lunny
Copy link
Member

@lunny lunny commented Jul 16, 2025

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 using a status column to mark attachments as deleted. These marked attachments are excluded from all UI and API queries. A background cleanup queue is responsible for permanently deleting the files and then removing the corresponding database records. 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 and DeleteAttachmentsByComment are removed because only tests need them.

Fix #29715

Ensure that a review comment with no content is also deleted when its last associated code comment is removed.

Add API Support

Introduced API functionality for deleting code comments.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 16, 2025
@lunny lunny added the type/bug label Jul 16, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/frontend labels Jul 16, 2025
@lunny lunny added the backport/v1.24 This PR should be backported to Gitea 1.24 label Jul 16, 2025
@github-actions github-actions bot added the modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin label Jul 17, 2025
@lunny lunny removed the backport/v1.24 This PR should be backported to Gitea 1.24 label Jul 17, 2025
@lunny lunny marked this pull request as draft July 17, 2025 07:04
@lunny lunny force-pushed the lunny/fix_bug_delete_code_comment branch from 026b762 to f3d0e51 Compare July 18, 2025 00:43
@github-actions github-actions bot removed the modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin label Jul 18, 2025
@lunny lunny force-pushed the lunny/fix_bug_delete_code_comment branch from 4ae54c8 to 97556a8 Compare July 19, 2025 00:44
@lunny lunny changed the title Fix deleting code comment bug Improve attachments deletion Jul 19, 2025
@lunny lunny added this to the 1.25.0 milestone Jul 19, 2025
@lunny lunny marked this pull request as ready for review July 19, 2025 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/api This PR adds API routes or modifies them modifies/frontend modifies/go Pull requests that update Go code modifies/migrations modifies/translation type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When deleting code review comment, the activity log will not be deleted
2 participants