From 901b32ce166b047ad9106d0672f6961599c50ef4 Mon Sep 17 00:00:00 2001 From: Gusted Date: Thu, 30 Jan 2025 12:04:14 +0100 Subject: [PATCH] chore: Remove `DeleteAttachmentsByIssue` - Introduced in 4617bef8954deeef5bd2ba36d84aba3b05a4dd83 and removed in ab2d0b3b442a2dc9ad0197f6e97760f5dd6148d6. --- .deadcode-out | 1 - models/repo/attachment.go | 10 ---------- models/repo/attachment_test.go | 6 +----- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/.deadcode-out b/.deadcode-out index 9eb1748f84..40c1ec7e01 100644 --- a/.deadcode-out +++ b/.deadcode-out @@ -65,7 +65,6 @@ code.gitea.io/gitea/models/project ChangeProjectStatus code.gitea.io/gitea/models/repo - DeleteAttachmentsByIssue WatchRepoMode code.gitea.io/gitea/models/user diff --git a/models/repo/attachment.go b/models/repo/attachment.go index 128bcebb60..b95d785fa5 100644 --- a/models/repo/attachment.go +++ b/models/repo/attachment.go @@ -219,16 +219,6 @@ func DeleteAttachments(ctx context.Context, attachments []*Attachment, remove bo return int(cnt), nil } -// DeleteAttachmentsByIssue deletes all attachments associated with the given issue. -func DeleteAttachmentsByIssue(ctx context.Context, issueID int64, remove bool) (int, error) { - attachments, err := GetAttachmentsByIssueID(ctx, issueID) - if err != nil { - return 0, err - } - - return DeleteAttachments(ctx, attachments, remove) -} - // DeleteAttachmentsByComment deletes all attachments associated with the given comment. func DeleteAttachmentsByComment(ctx context.Context, commentID int64, remove bool) (int, error) { attachments, err := GetAttachmentsByCommentID(ctx, commentID) diff --git a/models/repo/attachment_test.go b/models/repo/attachment_test.go index 23945ba1d3..881a40c3e7 100644 --- a/models/repo/attachment_test.go +++ b/models/repo/attachment_test.go @@ -46,11 +46,7 @@ func TestGetByCommentOrIssueID(t *testing.T) { func TestDeleteAttachments(t *testing.T) { require.NoError(t, unittest.PrepareTestDatabase()) - count, err := repo_model.DeleteAttachmentsByIssue(db.DefaultContext, 4, false) - require.NoError(t, err) - assert.Equal(t, 2, count) - - count, err = repo_model.DeleteAttachmentsByComment(db.DefaultContext, 2, false) + count, err := repo_model.DeleteAttachmentsByComment(db.DefaultContext, 2, false) require.NoError(t, err) assert.Equal(t, 2, count)