refactor: update id fields
This commit is contained in:
parent
75e5838b01
commit
09f9a5bdfd
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
type Tus struct {
|
||||
gorm.Model
|
||||
UploadID string `gorm:"primaryKey"`
|
||||
Id string
|
||||
ID uint64 `gorm:"primaryKey"`
|
||||
UploadID string
|
||||
Hash string
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -79,8 +79,8 @@ func Init() *tusd.Handler {
|
|||
},
|
||||
PreFinishResponseCallback: func(hook tusd.HookEvent) error {
|
||||
tusEntry := &model.Tus{
|
||||
Id: hook.Upload.ID,
|
||||
Hash: hook.Upload.MetaData[HASH_META_HEADER],
|
||||
UploadID: hook.Upload.ID,
|
||||
Hash: hook.Upload.MetaData[HASH_META_HEADER],
|
||||
}
|
||||
|
||||
if err := db.Get().Create(tusEntry).Error; err != nil {
|
||||
|
@ -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" {
|
||||
|
|
Loading…
Reference in New Issue