fix: TusUploadExists needs to operate on TusUpload not Upload

This commit is contained in:
Derrick Hammer 2024-01-20 07:05:27 -05:00
parent e8fbe46dfc
commit 8c86ecc5b7
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 4 additions and 4 deletions

View File

@ -18,7 +18,7 @@ type StorageService interface {
GetHashSmall(file io.ReadSeeker) ([]byte, error) GetHashSmall(file io.ReadSeeker) ([]byte, error)
GetHash(file io.Reader) ([]byte, error) GetHash(file io.Reader) ([]byte, error)
CreateUpload(hash []byte, uploaderID uint, uploaderIP string, size uint64, protocol string) (*models.Upload, error) CreateUpload(hash []byte, uploaderID uint, uploaderIP string, size uint64, protocol string) (*models.Upload, error)
TusUploadExists(hash []byte) (bool, models.Upload) TusUploadExists(hash []byte) (bool, models.TusUpload)
CreateTusUpload(hash []byte, uploadID string, uploaderID uint, uploaderIP string, protocol string) (*models.TusUpload, error) CreateTusUpload(hash []byte, uploadID string, uploaderID uint, uploaderIP string, protocol string) (*models.TusUpload, error)
TusUploadProgress(uploadID string) error TusUploadProgress(uploadID string) error
DeleteTusUpload(uploadID string) error DeleteTusUpload(uploadID string) error

View File

@ -374,11 +374,11 @@ func (s *StorageServiceImpl) tusWorker() {
} }
} }
func (s *StorageServiceImpl) TusUploadExists(hash []byte) (bool, models.Upload) { func (s *StorageServiceImpl) TusUploadExists(hash []byte) (bool, models.TusUpload) {
hashStr := hex.EncodeToString(hash) hashStr := hex.EncodeToString(hash)
var upload models.Upload var upload models.TusUpload
result := s.portal.Database().Model(&models.Upload{}).Where(&models.Upload{Hash: hashStr}).First(&upload) result := s.portal.Database().Model(&models.TusUpload{}).Where(&models.TusUpload{Hash: hashStr}).First(&upload)
return result.RowsAffected > 0, upload return result.RowsAffected > 0, upload
} }