Skip to content

Critical bug: Attachments were accidentally deleted #4210

@ghost

Description

  • Gitea version (or commit ref): 1.4.2 / af57d6a
  • Git version: N/A
  • Operating system: N/A
  • Database:
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist: N/A

Description

Steps to Reproduce

  1. Create repository: "Repo1"
  2. Create an issue and upload some attachments
    (https://try.gitea.io allow image/jpeg|image/png|application/zip|application/gzip)
  3. Create repository: "Repo2"
  4. Create an issue in "Repo2"
  5. Delete "Repo2"
  6. Any attachments uploaded to issue/release/PR were accidentally deleted from database and disk, no matter which user uploaded the files (Attachments uploaded to comment are not affected)

I think it's caused by #1092

if _, err = sess.In("issue_id", issueIDs).Delete(&Comment{}); err != nil {

c.ID == 0 here

func (c *Comment) AfterDelete() {
_, err := DeleteAttachmentsByComment(c.ID, true)
if err != nil {
log.Info("Could not delete files for comment %d on issue #%d: %s", c.ID, c.IssueID, err)
}
}

Screenshots

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/criticalThis issue should be fixed ASAP. If it is a PR, the PR should be merged ASAPtype/bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions