fix: Use gorm save, and return nil if successful

This commit is contained in:
Derrick Hammer 2023-05-23 20:16:26 -04:00
parent 038d2c440b
commit 26042b62ac
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 1 deletions

View File

@ -231,11 +231,13 @@ func (upload *fileUpload) writeInfo() error {
if tusRecord != nil { if tusRecord != nil {
tusRecord.Info = string(data) tusRecord.Info = string(data)
if ret := db.Get().Update("info", &tusRecord); ret.Error != nil { if ret := db.Get().Save(&tusRecord); ret.Error != nil {
logger.Get().Error("failed to update tus entry", zap.Error(ret.Error)) logger.Get().Error("failed to update tus entry", zap.Error(ret.Error))
return ret.Error return ret.Error
} }
return nil
} }
tusRecord = &model.Tus{UploadID: upload.info.ID, Hash: upload.hash, Info: string(data)} tusRecord = &model.Tus{UploadID: upload.info.ID, Hash: upload.hash, Info: string(data)}