feat: add GetUploadSize

This commit is contained in:
Derrick Hammer 2024-03-09 15:37:16 -05:00
parent 887f51f88d
commit f3040399e4
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 20 additions and 0 deletions

View File

@ -309,6 +309,26 @@ func (t *TusHandler) SetStorageProtocol(storageProtocol storage.StorageProtocol)
t.storageProtocol = storageProtocol t.storageProtocol = storageProtocol
} }
func (t *TusHandler) GetUploadSize(ctx context.Context, hash []byte) (int64, error) {
exists, upload := t.UploadExists(ctx, hash)
if !exists {
return 0, metadata.ErrNotFound
}
meta, err := t.tusStore.GetUpload(ctx, upload.UploadID)
if err != nil {
return 0, err
}
info, err := meta.GetInfo(ctx)
if err != nil {
return 0, err
}
return info.Size, nil
}
func (t *TusHandler) uploadTask(hash []byte) error { func (t *TusHandler) uploadTask(hash []byte) error {
ctx := context.Background() ctx := context.Background()
exists, upload := t.UploadExists(ctx, hash) exists, upload := t.UploadExists(ctx, hash)