From 09f9a5bdfda3610da61b10a1961b68499ad82660 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 22 May 2023 10:59:16 -0400 Subject: [PATCH] refactor: update id fields --- model/tus.go | 4 ++-- service/files/files.go | 2 +- tus/tus.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/model/tus.go b/model/tus.go index a9777bc..ede6ef2 100644 --- a/model/tus.go +++ b/model/tus.go @@ -6,7 +6,7 @@ import ( type Tus struct { gorm.Model - UploadID string `gorm:"primaryKey"` - Id string + ID uint64 `gorm:"primaryKey"` + UploadID string Hash string } diff --git a/service/files/files.go b/service/files/files.go index d0f81f6..a40767a 100644 --- a/service/files/files.go +++ b/service/files/files.go @@ -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 diff --git a/tus/tus.go b/tus/tus.go index 0e5e13e..d058dd4 100644 --- a/tus/tus.go +++ b/tus/tus.go @@ -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" {