From cceb30b2fbf03588b790feb6b49aeeed8b3f5918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Eduardo=20Jer=C3=A9z=20Gir=C3=B3n?= Date: Sat, 3 Aug 2024 22:22:45 -0600 Subject: [PATCH] Refactor storage methods to remove unused code --- internal/integration/storage/local.go | 15 ++++----------- internal/integration/storage/s3.go | 24 ------------------------ 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/internal/integration/storage/local.go b/internal/integration/storage/local.go index 1c1dfc9..6ecf5d3 100644 --- a/internal/integration/storage/local.go +++ b/internal/integration/storage/local.go @@ -51,15 +51,8 @@ func (Client) LocalDelete(relativeFilePath string) error { return nil } -// LocalReadFile Reads a file using the provided path relative to the local -// backups directory. -func (Client) LocalReadFile(relativeFilePath string) (io.ReadCloser, error) { - fullPath := strutil.CreatePath(true, localBackupsDir, relativeFilePath) - - file, err := os.Open(fullPath) - if err != nil { - return nil, fmt.Errorf("failed to open file %s: %w", fullPath, err) - } - - return file, nil +// LocalGetFullPath Returns the full path of a file using the provided relative +// file path to the local backups directory. +func (Client) LocalGetFullPath(relativeFilePath string) string { + return strutil.CreatePath(true, localBackupsDir, relativeFilePath) } diff --git a/internal/integration/storage/s3.go b/internal/integration/storage/s3.go index 841ea0a..c9929e2 100644 --- a/internal/integration/storage/s3.go +++ b/internal/integration/storage/s3.go @@ -129,27 +129,3 @@ func (Client) S3GetDownloadLink( return url, nil } - -// S3ReadFile reads a file from S3 -func (Client) S3ReadFile( - accessKey, secretKey, region, endpoint, bucketName, key string, -) (io.ReadCloser, error) { - s3Client, err := createS3Client( - accessKey, secretKey, region, endpoint, - ) - if err != nil { - return nil, err - } - - key = strutil.RemoveLeadingSlash(key) - - resp, err := s3Client.GetObject(&s3.GetObjectInput{ - Bucket: aws.String(bucketName), - Key: aws.String(key), - }) - if err != nil { - return nil, fmt.Errorf("failed to read file from S3: %w", err) - } - - return resp.Body, nil -}