Browse Source

Fix some bug

tags/vopendata0.1.2
Lunny Xiao yan 5 years ago
parent
commit
889295fdac
5 changed files with 17 additions and 8 deletions
  1. +3
    -5
      integrations/attachment_test.go
  2. +2
    -2
      models/repo.go
  3. +4
    -0
      modules/storage/local.go
  4. +4
    -0
      modules/storage/minio.go
  5. +4
    -1
      modules/storage/storage.go

+ 3
- 5
integrations/attachment_test.go View File

@@ -9,14 +9,12 @@ import (
"image"
"image/png"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
"path"
"strings"
"testing"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/storage"
"code.gitea.io/gitea/modules/test"

"github.com/stretchr/testify/assert"
@@ -123,7 +121,7 @@ func TestGetAttachment(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
//Write empty file to be available for response
if tc.createFile {
err = SaveAttachment(tc.uuid, strings.NewReader("hello world"))
err = storage.Attachments.Save(tc.RelativePath(), strings.NewReader("hello world"))
assert.NoError(t, err)
}
//Actual test


+ 2
- 2
models/repo.go View File

@@ -1549,7 +1549,7 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
}
releaseAttachments := make([]string, 0, len(attachments))
for i := 0; i < len(attachments); i++ {
releaseAttachments = append(releaseAttachments, attachments[i].UUID)
releaseAttachments = append(releaseAttachments, attachments[i].RelativePath())
}

if err = deleteBeans(sess,
@@ -1628,7 +1628,7 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
}
attachmentPaths := make([]string, 0, len(attachments))
for j := range attachments {
attachmentPaths = append(attachmentPaths, attachments[j].UUID)
attachmentPaths = append(attachmentPaths, attachments[j].RelativePath())
}

if _, err = sess.In("issue_id", deleteCond).


+ 4
- 0
modules/storage/local.go View File

@@ -1,3 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package storage

import (


+ 4
- 0
modules/storage/minio.go View File

@@ -1,3 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package storage

import (


+ 4
- 1
modules/storage/storage.go View File

@@ -1,3 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package storage

import (
@@ -39,4 +43,3 @@ func Init() error {

return nil
}


Loading…
Cancel
Save