feat: add TusUploadCompleted method
This commit is contained in:
parent
aab4bb4d69
commit
e0c6c88e75
|
@ -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
|
||||||
|
|
|
@ -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{})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue