Skip to content

fix: cascade purge attachments, comments, and votes when post/comment is deleted#1559

Closed
1795771535y-cell wants to merge 1 commit into
getfider:mainfrom
1795771535y-cell:main
Closed

fix: cascade purge attachments, comments, and votes when post/comment is deleted#1559
1795771535y-cell wants to merge 1 commit into
getfider:mainfrom
1795771535y-cell:main

Conversation

@1795771535y-cell

Copy link
Copy Markdown

Problem

When a post is deleted from the WebUI (via setPostResponse with PostDeleted status), associated data is left orphaned in the database:

  • Attachments (post-level and comment-level) are not purged
  • Comments remain without deleted_at being set
  • Post votes (post_votes) are not cleaned up
  • Comment attachments are not cleaned up when individual comments are deleted

This causes the database to grow over time with unlinked data. Affected tables: �ttachments, comments, post_votes, and indirectly �lobs.

Fixes #1149

Changes

post.go - setPostResponse

When status changes to PostDeleted, added cascade cleanup:

  1. Soft-delete all comments on the post (SET deleted_at)
  2. Delete all attachments for the post (both post and comment-level)
  3. Delete all votes for the post

comment.go - deleteComment

When a comment is soft-deleted, also delete its associated attachments.

Testing

  • Existing post/comment attachment tests pass
  • Manual verification: after post deletion, �ttachments, comments, and post_votes are properly cleaned up

… is deleted

When a post is set to PostDeleted via setPostResponse:
- Soft-delete all associated comments (set deleted_at)
- Delete all attachments (both post-level and comment-level)
- Delete all post_votes

When a comment is soft-deleted via deleteComment:
- Delete comment-level attachments

This prevents orphaned data from accumulating in the DB over time.

Fixes getfider#1149
@1795771535y-cell

Copy link
Copy Markdown
Author

Closing: no maintainer response after extended wait. Thanks for the opportunity.

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.

[BUG] The information in the DB is not purged after deleting from the WebUI

1 participant