-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix doctor deleting orphaned issues attachments #34142
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?
Changes from 1 commit
49b0039
e332bdf
d4f5ee3
675ba42
b241773
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,3 +323,32 @@ func deleteIssue(ctx context.Context, issue *issues_model.Issue) error { | |
|
||
return committer.Commit() | ||
} | ||
|
||
// DeleteOrphanedIssues delete issues without a repo | ||
func DeleteOrphanedIssues(ctx context.Context) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can some codes above be used in this function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it could be. But that will need much more changes. This PR will only fix the bug when deleting attachments. That could be another PR. |
||
var attachmentPaths []string | ||
err := db.WithTx(ctx, func(ctx context.Context) error { | ||
repoIDs, err := issues_model.GetOrphanedIssueRepoIDs(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
for i := range repoIDs { | ||
paths, err := issues_model.DeleteIssuesByRepoID(ctx, repoIDs[i]) | ||
if err != nil { | ||
return err | ||
} | ||
attachmentPaths = append(attachmentPaths, paths...) | ||
} | ||
|
||
return nil | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Remove issue attachment files. | ||
for i := range attachmentPaths { | ||
system_model.RemoveStorageWithNotice(ctx, storage.Attachments, "Delete issue attachment", attachmentPaths[i]) | ||
} | ||
return nil | ||
} |
Uh oh!
There was an error while loading. Please reload this page.