diff options
author | David Svantesson | 2019-09-26 15:16:47 +0200 |
---|---|---|
committer | Lunny Xiao | 2019-09-26 21:16:47 +0800 |
commit | 7156e2a71aa97565927df83df78d384b84de929e (patch) | |
tree | 771a3d7d6434b5481effc57b1c275321331eabe1 | |
parent | e51d91a258630eb3bdd662eea34ba2ca9341a915 (diff) |
Fix API for edit and delete release attachment (#8290)
* Add logging for when user requested attachment doesn't belong to the specified release.
* Fix API to use correct variable for release asset (attachment)
-rw-r--r-- | routers/api/v1/repo/release_attachment.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go index aa2cc14cf..d0d02139d 100644 --- a/routers/api/v1/repo/release_attachment.go +++ b/routers/api/v1/repo/release_attachment.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" @@ -57,6 +58,7 @@ func GetReleaseAttachment(ctx *context.APIContext) { return } if attach.ReleaseID != releaseID { + log.Info("User requested attachment is not in release, release_id %v, attachment_id: %v", releaseID, attachID) ctx.NotFound() return } @@ -256,13 +258,14 @@ func EditReleaseAttachment(ctx *context.APIContext, form api.EditAttachmentOptio // Check if release exists an load release releaseID := ctx.ParamsInt64(":id") - attachID := ctx.ParamsInt64(":attachment") + attachID := ctx.ParamsInt64(":asset") attach, err := models.GetAttachmentByID(attachID) if err != nil { ctx.Error(500, "GetAttachmentByID", err) return } if attach.ReleaseID != releaseID { + log.Info("User requested attachment is not in release, release_id %v, attachment_id: %v", releaseID, attachID) ctx.NotFound() return } @@ -313,13 +316,14 @@ func DeleteReleaseAttachment(ctx *context.APIContext) { // Check if release exists an load release releaseID := ctx.ParamsInt64(":id") - attachID := ctx.ParamsInt64(":attachment") + attachID := ctx.ParamsInt64(":asset") attach, err := models.GetAttachmentByID(attachID) if err != nil { ctx.Error(500, "GetAttachmentByID", err) return } if attach.ReleaseID != releaseID { + log.Info("User requested attachment is not in release, release_id %v, attachment_id: %v", releaseID, attachID) ctx.NotFound() return } |