mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-01 12:22:11 +00:00
Fix potential bugs (#10513)
* use e if it is an option * potential nil so check err first * check err first * m == nil already checked
This commit is contained in:
parent
15fbf509d3
commit
e57ac841de
7 changed files with 14 additions and 10 deletions
|
@ -70,14 +70,14 @@ func UploadAttachment(ctx *context.Context) {
|
|||
func DeleteAttachment(ctx *context.Context) {
|
||||
file := ctx.Query("file")
|
||||
attach, err := models.GetAttachmentByUUID(file)
|
||||
if !ctx.IsSigned || (ctx.User.ID != attach.UploaderID) {
|
||||
ctx.Error(403)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
ctx.Error(400, err.Error())
|
||||
return
|
||||
}
|
||||
if !ctx.IsSigned || (ctx.User.ID != attach.UploaderID) {
|
||||
ctx.Error(403)
|
||||
return
|
||||
}
|
||||
err = models.DeleteAttachment(attach, true)
|
||||
if err != nil {
|
||||
ctx.Error(500, fmt.Sprintf("DeleteAttachment: %v", err))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue