From a54238d4b673492c03f251bdd252bc01d0c51919 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 28 Mar 2024 17:43:32 -0400 Subject: [PATCH] feat: add TusHandler::Uploads --- protocols/s5/tus.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/protocols/s5/tus.go b/protocols/s5/tus.go index e426d49..5fff09f 100644 --- a/protocols/s5/tus.go +++ b/protocols/s5/tus.go @@ -175,6 +175,17 @@ func (t *TusHandler) UploadExists(ctx context.Context, hash []byte) (bool, model return result.RowsAffected > 0, upload } +func (t *TusHandler) Uploads(ctx context.Context, uploaderID uint) ([]models.TusUpload, error) { + var uploads []models.TusUpload + result := t.db.WithContext(ctx).Model(&models.TusUpload{}).Where(&models.TusUpload{UploaderID: uploaderID}).Find(&uploads) + + if result.Error != nil { + return nil, result.Error + } + + return uploads, nil +} + func (t *TusHandler) CreateUpload(ctx context.Context, hash []byte, uploadID string, uploaderID uint, uploaderIP string, protocol string) (*models.TusUpload, error) { upload := &models.TusUpload{ Hash: hash,