refactor: update id fields
This commit is contained in:
parent
75e5838b01
commit
09f9a5bdfd
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
type Tus struct {
|
type Tus struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
UploadID string `gorm:"primaryKey"`
|
ID uint64 `gorm:"primaryKey"`
|
||||||
Id string
|
UploadID string
|
||||||
Hash string
|
Hash string
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ func Download(hash string) (io.Reader, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
upload, err := shared.GetTusStore().GetUpload(context.Background(), tusData.Id)
|
upload, err := shared.GetTusStore().GetUpload(context.Background(), tusData.UploadID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
shared.GetLogger().Error("Failed querying tus upload", zap.Error(err))
|
shared.GetLogger().Error("Failed querying tus upload", zap.Error(err))
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -79,7 +79,7 @@ func Init() *tusd.Handler {
|
||||||
},
|
},
|
||||||
PreFinishResponseCallback: func(hook tusd.HookEvent) error {
|
PreFinishResponseCallback: func(hook tusd.HookEvent) error {
|
||||||
tusEntry := &model.Tus{
|
tusEntry := &model.Tus{
|
||||||
Id: hook.Upload.ID,
|
UploadID: hook.Upload.ID,
|
||||||
Hash: hook.Upload.MetaData[HASH_META_HEADER],
|
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))
|
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)
|
ret := db.Get().Where(tusUpload).First(&tusUpload)
|
||||||
|
|
||||||
if ret.Error != nil && ret.Error.Error() != "record not found" {
|
if ret.Error != nil && ret.Error.Error() != "record not found" {
|
||||||
|
|
Loading…
Reference in New Issue