stop frontend crashing 😡
This commit is contained in:
parent
c99c202bc8
commit
e3049dddd9
1 changed files with 9 additions and 0 deletions
|
@ -103,6 +103,11 @@ func RegisterFileRoutes(cfg *types.StereoConfig, api *gin.RouterGroup) {
|
|||
cfg.Database.First(&file, fileID)
|
||||
|
||||
if file == nil {
|
||||
err := cfg.Database.Delete(&file).Error
|
||||
if err != nil {
|
||||
types.ErrorDatabase.Throw(c, err)
|
||||
return
|
||||
}
|
||||
types.ErrorFileNotFound.Throw(c, nil)
|
||||
return
|
||||
}
|
||||
|
@ -149,6 +154,10 @@ func RegisterFileRoutes(cfg *types.StereoConfig, api *gin.RouterGroup) {
|
|||
types.ErrorS3.Throw(c, err)
|
||||
return
|
||||
}
|
||||
if _, err := object.Stat(); err != nil {
|
||||
types.ErrorFileNotFound.Throw(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.DataFromReader(200, file.Size, file.Mime, object, nil)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue