diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-19 21:39:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-19 21:39:57 +0800 |
commit | fc3d0826096943b979717ed46c9a4cfd86e06106 (patch) | |
tree | 3143882ccf4dea3a8bf2a0de9c8da9a4efec26ce /routers/web/repo/attachment.go | |
parent | 7a0347315995b25bcb2dca4786504fb699b5f004 (diff) | |
download | gitea-fc3d0826096943b979717ed46c9a4cfd86e06106.tar.gz gitea-fc3d0826096943b979717ed46c9a4cfd86e06106.zip |
Move attachment into models/repo/ (#17650)
* Move attachment into models/repo/
* Fix test
* Fix bug
Diffstat (limited to 'routers/web/repo/attachment.go')
-rw-r--r-- | routers/web/repo/attachment.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/routers/web/repo/attachment.go b/routers/web/repo/attachment.go index 3968d27652..303eee24d1 100644 --- a/routers/web/repo/attachment.go +++ b/routers/web/repo/attachment.go @@ -9,6 +9,7 @@ import ( "net/http" "code.gitea.io/gitea/models" + repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/httpcache" "code.gitea.io/gitea/modules/log" @@ -62,7 +63,7 @@ func uploadAttachment(ctx *context.Context, repoID int64, allowedTypes string) { // DeleteAttachment response for deleting issue's attachment func DeleteAttachment(ctx *context.Context) { file := ctx.FormString("file") - attach, err := models.GetAttachmentByUUID(file) + attach, err := repo_model.GetAttachmentByUUID(file) if err != nil { ctx.Error(http.StatusBadRequest, err.Error()) return @@ -71,7 +72,7 @@ func DeleteAttachment(ctx *context.Context) { ctx.Error(http.StatusForbidden) return } - err = models.DeleteAttachment(attach, true) + err = repo_model.DeleteAttachment(attach, true) if err != nil { ctx.Error(http.StatusInternalServerError, fmt.Sprintf("DeleteAttachment: %v", err)) return @@ -83,9 +84,9 @@ func DeleteAttachment(ctx *context.Context) { // GetAttachment serve attachements func GetAttachment(ctx *context.Context) { - attach, err := models.GetAttachmentByUUID(ctx.Params(":uuid")) + attach, err := repo_model.GetAttachmentByUUID(ctx.Params(":uuid")) if err != nil { - if models.IsErrAttachmentNotExist(err) { + if repo_model.IsErrAttachmentNotExist(err) { ctx.Error(http.StatusNotFound) } else { ctx.ServerError("GetAttachmentByUUID", err) @@ -93,7 +94,7 @@ func GetAttachment(ctx *context.Context) { return } - repository, unitType, err := attach.LinkedRepository() + repository, unitType, err := models.LinkedRepository(attach) if err != nil { ctx.ServerError("LinkedRepository", err) return |