diff --git a/interfaces/storage.go b/interfaces/storage.go index c22fb1b..824d9d4 100644 --- a/interfaces/storage.go +++ b/interfaces/storage.go @@ -21,6 +21,7 @@ type StorageService interface { TusUploadExists(hash []byte) (bool, models.TusUpload) CreateTusUpload(hash []byte, uploadID string, uploaderID uint, uploaderIP string, protocol string) (*models.TusUpload, error) TusUploadProgress(uploadID string) error + TusUploadCompleted(uploadID string) error DeleteTusUpload(uploadID string) error ScheduleTusUpload(uploadID string, attempt int) error Tus() *tusd.Handler diff --git a/storage/storage.go b/storage/storage.go index 468dec1..838778c 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -418,6 +418,21 @@ func (s *StorageServiceImpl) TusUploadProgress(uploadID string) error { 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 { result := s.portal.Database().Where(&models.TusUpload{UploadID: uploadID}).Delete(&models.TusUpload{})