There is no delete mechanism for attachments #237

Closed
opened 2025-11-02 03:14:59 -06:00 by GiteaMirror · 13 comments
Owner

Originally created by @couling on GitHub (Jan 15, 2017).

Refering to:

  • Gitea version (or commit ref): v1.0.0-126-g302fa42
  • Feature Request.

There is no delete mechanism at all for attachments.

  • The user should be presented with the option to delete any / all attachments from an issue comment.
  • Attachments should be deleted immediately when an issue / issue comment are deleted.
  • Attachments should be deleted immediately when a release is deleted
  • "Orphaned"Attachments should be deleted periodically (eg: cron job). Orphaned attachments have both attachment.CommentID and attachment.ReleaseId of 0. They occur when a user starts creating an issue, uploads an attachment and then closes the browser without submitting.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Originally created by @couling on GitHub (Jan 15, 2017). Refering to: - Gitea version (or commit ref): v1.0.0-126-g302fa42 - Feature Request. There is no delete mechanism at all for attachments. - [ ] The user should be presented with the option to delete any / all attachments from an issue comment. - [x] Attachments should be deleted immediately when an issue / issue comment are deleted. - [x] Attachments should be deleted immediately when a release is deleted - [ ] "Orphaned"Attachments should be deleted periodically (eg: cron job). *Orphaned attachments have both `attachment.CommentID` and `attachment.ReleaseId` of `0`. They occur when a user starts creating an issue, uploads an attachment and then closes the browser without submitting.* --- Want to back this issue? [**Post a bounty on it!**](https://www.bountysource.com/issues/40975238-there-is-no-delete-mechanism-for-attachments?utm_campaign=plugin&utm_content=tracker%2F47456670&utm_medium=issues&utm_source=github) We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F47456670&utm_medium=issues&utm_source=github).
GiteaMirror added the issue/confirmedtype/enhancement labels 2025-11-02 03:14:59 -06:00
Author
Owner

@bkcsoft commented on GitHub (Jan 19, 2017):

Also when a release is removed? (since that is now a thing 😄 #673 )

@bkcsoft commented on GitHub (Jan 19, 2017): Also when a release is removed? (since that is now a thing 😄 #673 )
Author
Owner

@couling commented on GitHub (Jan 20, 2017):

Actually it looks like the code tries to delete an attachment on deleting a comment.

See Here

However it doesn't manage to do so.

@couling commented on GitHub (Jan 20, 2017): Actually it looks like the code tries to delete an attachment on deleting a comment. [See Here](https://github.com/go-gitea/gitea/blob/a6f5efa0bb7bab30b6acd654c5ccf1c273c8b60c/models/issue_comment.go#L119) However it doesn't manage to do so.
Author
Owner

@couling commented on GitHub (Jan 20, 2017):

Okay so this doesn't trigger the AfterDelete(). I guess that's an xorm bug. I think for the time being I'm going to work around it and explicitly Delete the attachment in DeleteCommentById

@couling commented on GitHub (Jan 20, 2017): Okay so [this](https://github.com/go-gitea/gitea/blob/a6f5efa0bb7bab30b6acd654c5ccf1c273c8b60c/models/issue_comment.go#L473) doesn't trigger the `AfterDelete()`. I guess that's an xorm bug. I think for the time being I'm going to work around it and explicitly Delete the attachment in `DeleteCommentById`
Author
Owner

@lunny commented on GitHub (Jan 20, 2017):

change this to below code, then AfterDelete() will work.

if _, err = sess.Delete(&Comment{
ID: comment.ID,
}); err != nil {
		return err
	}
@lunny commented on GitHub (Jan 20, 2017): change [this](https://github.com/go-gitea/gitea/blob/a6f5efa0bb7bab30b6acd654c5ccf1c273c8b60c/models/issue_comment.go#L473) to below code, then `AfterDelete()` will work. ```Go if _, err = sess.Delete(&Comment{ ID: comment.ID, }); err != nil { return err } ```
Author
Owner

@appleboy commented on GitHub (Jan 20, 2017):

@lunny I will take it.

@appleboy commented on GitHub (Jan 20, 2017): @lunny I will take it.
Author
Owner

@appleboy commented on GitHub (Jan 20, 2017):

@lunny we need to merge this XORM PR first https://github.com/go-xorm/xorm/pull/525

@appleboy commented on GitHub (Jan 20, 2017): @lunny we need to merge this XORM PR first https://github.com/go-xorm/xorm/pull/525
Author
Owner

@appleboy commented on GitHub (Jan 25, 2017):

#704 also fix item two.

Attachments should be deleted immediately when an issue / issue comment or release are deleted.

cc @couling

@appleboy commented on GitHub (Jan 25, 2017): #704 also fix item two. > Attachments should be deleted immediately when an issue / issue comment or release are deleted. cc @couling
Author
Owner

@bkcsoft commented on GitHub (Feb 28, 2017):

These aren't all fixed.

@bkcsoft commented on GitHub (Feb 28, 2017): These aren't all fixed.
Author
Owner

@ghost commented on GitHub (Feb 28, 2017):

The user should be presented with the option to delete any / all previously added attachments while editing a release.

@ghost commented on GitHub (Feb 28, 2017): The user should be presented with the option to delete any / all previously added attachments while editing a release.
Author
Owner

@ghost commented on GitHub (Mar 21, 2017):

@gmastergreatee You are right! In addition to that, you cannot delete and recreate a release because it also deletes the git tag. One should split this.

@ghost commented on GitHub (Mar 21, 2017): @gmastergreatee You are right! In addition to that, you cannot delete and recreate a release because it also deletes the git tag. One should split this.
Author
Owner

@thmo commented on GitHub (Sep 28, 2017):

As an additional issue, the attachments remain on disk even after deleting the release itself (see #2618).

@thmo commented on GitHub (Sep 28, 2017): As an additional issue, the attachments remain on disk even after deleting the release itself (see #2618).
Author
Owner

@stale[bot] commented on GitHub (Feb 12, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Feb 12, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@6543 commented on GitHub (Apr 29, 2021):

closed by #14130

@6543 commented on GitHub (Apr 29, 2021): closed by #14130
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#237