fix(backend/db): fix error and status handling in some functions
This commit is contained in:
parent
dbc34a8e0d
commit
35d41a46c0
@ -53,6 +53,7 @@ func FileGetSlice(user_id int, filter, sort string, limit, offset int) (files mo
|
|||||||
statusCode, err = handleDBError(err)
|
statusCode, err = handleDBError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer rows.Close()
|
||||||
count := 0
|
count := 0
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var file models.FileItem
|
var file models.FileItem
|
||||||
@ -120,6 +121,11 @@ func FileGet(user_id int, file_id string) (file models.FileFull, statusCode int,
|
|||||||
JOIN data.file_tag ft ON ft.tag_id=t.id
|
JOIN data.file_tag ft ON ft.tag_id=t.id
|
||||||
WHERE ft.file_id=$1
|
WHERE ft.file_id=$1
|
||||||
`, file_id)
|
`, file_id)
|
||||||
|
if err != nil {
|
||||||
|
statusCode, err = handleDBError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var tag models.TagCore
|
var tag models.TagCore
|
||||||
err = rows.Scan(&tag.ID, &tag.Name, &tag.Color)
|
err = rows.Scan(&tag.ID, &tag.Name, &tag.Color)
|
||||||
@ -132,7 +138,9 @@ func FileGet(user_id int, file_id string) (file models.FileFull, statusCode int,
|
|||||||
err = rows.Err()
|
err = rows.Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
statusCode = http.StatusInternalServerError
|
statusCode = http.StatusInternalServerError
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
statusCode = http.StatusOK
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,6 +174,7 @@ func FileAdd(user_id int, name, mime string, datetime time.Time, notes string, m
|
|||||||
file.Name.Valid = (name != "")
|
file.Name.Valid = (name != "")
|
||||||
file.MIME.Name = mime
|
file.MIME.Name = mime
|
||||||
file.MIME.Extension = extension
|
file.MIME.Extension = extension
|
||||||
|
statusCode = http.StatusOK
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user