Skip to content

Commit

Permalink
client
Browse files Browse the repository at this point in the history
  • Loading branch information
or-shachar committed Nov 19, 2023
1 parent 39df3f7 commit b5a6143
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions cachers/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"io"
"log"
"runtime"
"strings"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -48,9 +47,7 @@ func NewS3Cache(bucketName string, cfg *aws.Config, cacheKey string, disk *DiskC
arc := runtime.GOARCH
// get current operating system
os := runtime.GOOS
// get current version of Go
ver := strings.ReplaceAll(strings.ReplaceAll(runtime.Version(), " ", "-"), ":", "-")
prefix := fmt.Sprintf("cache/%s/%s/%s/%s", cacheKey, arc, os, ver)
prefix := fmt.Sprintf("cache/%s/%s/%s", cacheKey, arc, os)
log.Printf("S3Cache: configured to s3://%s/%s", bucketName, prefix)
return &S3Cache{
Bucket: bucketName,
Expand All @@ -63,7 +60,7 @@ func NewS3Cache(bucketName string, cfg *aws.Config, cacheKey string, disk *DiskC
}
}

func (c *S3Cache) client(ctx context.Context) (*s3.Client, error) {
func (c *S3Cache) client() (*s3.Client, error) {
if c.s3Client != nil {
return c.s3Client, nil
}
Expand All @@ -87,7 +84,7 @@ func (c *S3Cache) Get(ctx context.Context, actionID string) (outputID, diskPath
if err == nil && outputID != "" {
return outputID, diskPath, nil
}
client, err := c.client(ctx)
client, err := c.client()
if err != nil {
if c.verbose {
log.Printf("error getting S3 client: %v", err)
Expand Down Expand Up @@ -195,7 +192,7 @@ func (c *S3Cache) Put(ctx context.Context, actionID, outputID string, size int64
return "", err
}

client, err := c.client(ctx)
client, err := c.client()
if err != nil {
return "", err
}
Expand Down

0 comments on commit b5a6143

Please sign in to comment.