From d7da471b8bd784ed6c65aca5b50777f2fd1231d9 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 16 Feb 2024 21:58:34 -0500 Subject: [PATCH] refactor: update parameters and change MultipartUpload to UploadObjectMultipart --- renter/renter.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/renter/renter.go b/renter/renter.go index 8423630..1d11425 100644 --- a/renter/renter.go +++ b/renter/renter.go @@ -4,6 +4,11 @@ import ( "context" "errors" "fmt" + "io" + "math" + "net/url" + "strconv" + "git.lumeweb.com/LumeWeb/portal/cron" "github.com/google/uuid" "github.com/spf13/viper" @@ -14,10 +19,6 @@ import ( workerClient "go.sia.tech/renterd/worker/client" "go.uber.org/fx" "go.uber.org/zap" - "io" - "math" - "net/url" - "strconv" ) type ReaderFactory func(start uint, end uint) (io.ReadCloser, error) @@ -71,10 +72,8 @@ func (r *RenterDefault) CreateBucketIfNotExists(bucket string) error { return nil } - if err != nil { - if !errors.Is(err, api.ErrBucketNotFound) { - return err - } + if !errors.Is(err, api.ErrBucketNotFound) { + return err } err = r.busClient.CreateBucket(context.Background(), bucket, api.CreateBucketOptions{ @@ -89,8 +88,8 @@ func (r *RenterDefault) CreateBucketIfNotExists(bucket string) error { return nil } -func (r *RenterDefault) UploadObject(ctx context.Context, file io.Reader, bucket string, hash string) error { - _, err := r.workerClient.UploadObject(ctx, file, bucket, hash, api.UploadObjectOptions{}) +func (r *RenterDefault) UploadObject(ctx context.Context, file io.Reader, bucket string, fileName string) error { + _, err := r.workerClient.UploadObject(ctx, file, bucket, fileName, api.UploadObjectOptions{}) if err != nil { return err @@ -120,8 +119,8 @@ func (r *RenterDefault) init() error { return nil } -func (r *RenterDefault) GetObject(ctx context.Context, protocol string, hash string, options api.DownloadObjectOptions) (*api.GetObjectResponse, error) { - return r.workerClient.GetObject(ctx, protocol, hash, options) +func (r *RenterDefault) GetObject(ctx context.Context, bucket string, fileName string, options api.DownloadObjectOptions) (*api.GetObjectResponse, error) { + return r.workerClient.GetObject(ctx, bucket, fileName, options) } func (r *RenterDefault) GetSetting(ctx context.Context, setting string, out any) error { @@ -134,12 +133,11 @@ func (r *RenterDefault) GetSetting(ctx context.Context, setting string, out any) return nil } -func (r *RenterDefault) MultipartUpload(params MultiPartUploadParams) error { +func (r *RenterDefault) UploadObjectMultipart(ctx context.Context, params *MultiPartUploadParams) error { size := params.Size rf := params.ReaderFactory bucket := params.Bucket fileName := params.FileName - ctx := context.Background() idHandler := params.UploadIDHandler var redundancy api.RedundancySettings