Skip to content

Commit 1e80a65

Browse files
committed
s3cache: use the s3util package where useful
1 parent 678ba5a commit 1e80a65

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

s3cache/s3cache.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import (
1818
"time"
1919

2020
"github.com/aws/aws-sdk-go-v2/service/s3"
21-
"github.com/aws/aws-sdk-go-v2/service/s3/types"
2221
"github.com/creachadair/gocache"
2322
"github.com/creachadair/gocache/cachedir"
2423
"github.com/creachadair/taskgroup"
24+
"github.com/tailscale/go-cache-plugin/internal/s3util"
2525
)
2626

2727
// Cache implements callbacks for a gocache.Server using an S3 bucket for
@@ -110,7 +110,7 @@ func (s *Cache) Get(ctx context.Context, actionID string) (objectID, diskPath st
110110
Key: s.actionKey(actionID),
111111
})
112112
if err != nil {
113-
if isNotExist(err) {
113+
if s3util.IsNotExist(err) {
114114
s.getFaultMiss.Add(1)
115115
return "", "", nil // cache miss, OK
116116
}
@@ -277,18 +277,6 @@ func (s *Cache) uploadConcurrency() int {
277277
return s.UploadConcurrency
278278
}
279279

280-
func isNotExist(err error) bool {
281-
var notFound *types.NotFound
282-
if errors.As(err, &notFound) {
283-
return true
284-
}
285-
var noSuchKey *types.NoSuchKey
286-
if errors.As(err, &noSuchKey) {
287-
return true
288-
}
289-
return errors.Is(err, os.ErrNotExist)
290-
}
291-
292280
func parseAction(r io.Reader) (objectID string, mtime time.Time, _ error) {
293281
data, err := io.ReadAll(r)
294282
if err != nil {

0 commit comments

Comments
 (0)