refactor: update id fields

This commit is contained in:
Derrick Hammer 2023-05-22 10:59:16 -04:00
parent 75e5838b01
commit 09f9a5bdfd
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 6 additions and 6 deletions

View File

@ -6,7 +6,7 @@ import (
type Tus struct {
gorm.Model
UploadID string `gorm:"primaryKey"`
Id string
ID uint64 `gorm:"primaryKey"`
UploadID string
Hash string
}

View File

@ -122,7 +122,7 @@ func Download(hash string) (io.Reader, error) {
return nil, err
}
upload, err := shared.GetTusStore().GetUpload(context.Background(), tusData.Id)
upload, err := shared.GetTusStore().GetUpload(context.Background(), tusData.UploadID)
if err != nil {
shared.GetLogger().Error("Failed querying tus upload", zap.Error(err))
return nil, err

View File

@ -79,7 +79,7 @@ func Init() *tusd.Handler {
},
PreFinishResponseCallback: func(hook tusd.HookEvent) error {
tusEntry := &model.Tus{
Id: hook.Upload.ID,
UploadID: hook.Upload.ID,
Hash: hook.Upload.MetaData[HASH_META_HEADER],
}
@ -169,7 +169,7 @@ func terminateUpload(upload tusd.Upload) error {
shared.GetLogger().Error("failed deleting tus upload", zap.Error(err))
}
tusUpload := &model.Tus{Id: info.ID}
tusUpload := &model.Tus{UploadID: info.ID}
ret := db.Get().Where(tusUpload).First(&tusUpload)
if ret.Error != nil && ret.Error.Error() != "record not found" {