feat: add TusUploadCompleted method

This commit is contained in:
Derrick Hammer 2024-01-22 17:49:03 -05:00
parent aab4bb4d69
commit e0c6c88e75
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 16 additions and 0 deletions

View File

@ -21,6 +21,7 @@ type StorageService interface {
TusUploadExists(hash []byte) (bool, models.TusUpload) 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
TusUploadCompleted(uploadID string) error
DeleteTusUpload(uploadID string) error DeleteTusUpload(uploadID string) error
ScheduleTusUpload(uploadID string, attempt int) error ScheduleTusUpload(uploadID string, attempt int) error
Tus() *tusd.Handler Tus() *tusd.Handler

View File

@ -418,6 +418,21 @@ func (s *StorageServiceImpl) TusUploadProgress(uploadID string) error {
return nil return nil
} }
func (s *StorageServiceImpl) TusUploadCompleted(uploadID string) error {
find := &models.TusUpload{UploadID: uploadID}
var upload models.TusUpload
result := s.portal.Database().Model(&models.TusUpload{}).Where(find).First(&upload)
if result.RowsAffected == 0 {
return errors.New("upload not found")
}
result = s.portal.Database().Model(&models.TusUpload{}).Where(find).Update("completed", true)
return nil
}
func (s *StorageServiceImpl) DeleteTusUpload(uploadID string) error { func (s *StorageServiceImpl) DeleteTusUpload(uploadID string) error {
result := s.portal.Database().Where(&models.TusUpload{UploadID: uploadID}).Delete(&models.TusUpload{}) result := s.portal.Database().Where(&models.TusUpload{UploadID: uploadID}).Delete(&models.TusUpload{})