summaryrefslogtreecommitdiffstats
path: root/services/release
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-09-08 23:19:30 +0800
committerGitHub <noreply@github.com>2021-09-08 17:19:30 +0200
commitddc709ff7f94bd627ac05209a16ea5a5e24b7413 (patch)
tree1420d827e00769c1a8330c6b1a80e7cbbc343332 /services/release
parentf55cd033ed8dbee04e90faede5cca2dcf697e102 (diff)
downloadgitea-ddc709ff7f94bd627ac05209a16ea5a5e24b7413.tar.gz
gitea-ddc709ff7f94bd627ac05209a16ea5a5e24b7413.zip
Add repo_id for attachment (#16958)
When create a new issue or comment and paste/upload an attachment/image, it will not assign an issue id before submit. So if user give up the creating, the attachments will lost key feature and become dirty content. We don't know if we need to delete the attachment even if the repository deleted. This PR add a repo_id in attachment table so that even if a new upload attachment with no issue_id or release_id but should have repo_id. When deleting a repository, they could also be deleted. Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'services/release')
-rw-r--r--services/release/release_test.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/services/release/release_test.go b/services/release/release_test.go
index 9f665fabab..936f2ab71c 100644
--- a/services/release/release_test.go
+++ b/services/release/release_test.go
@@ -12,6 +12,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
+ "code.gitea.io/gitea/services/attachment"
"github.com/stretchr/testify/assert"
)
@@ -101,10 +102,11 @@ func TestRelease_Create(t *testing.T) {
IsTag: false,
}, nil, ""))
- attach, err := models.NewAttachment(&models.Attachment{
+ attach, err := attachment.NewAttachment(&models.Attachment{
+ RepoID: repo.ID,
UploaderID: user.ID,
Name: "test.txt",
- }, []byte{}, strings.NewReader("testtest"))
+ }, strings.NewReader("testtest"))
assert.NoError(t, err)
var release = models.Release{
@@ -233,10 +235,11 @@ func TestRelease_Update(t *testing.T) {
assert.Equal(t, tagName, release.TagName)
// Add new attachments
- attach, err := models.NewAttachment(&models.Attachment{
+ attach, err := attachment.NewAttachment(&models.Attachment{
+ RepoID: repo.ID,
UploaderID: user.ID,
Name: "test.txt",
- }, []byte{}, strings.NewReader("testtest"))
+ }, strings.NewReader("testtest"))
assert.NoError(t, err)
assert.NoError(t, UpdateRelease(user, gitRepo, release, []string{attach.UUID}, nil, nil))