Drop the Exists call before loading the archive

This commit is contained in:
Neil Macneale IV
2025-02-28 13:07:42 -08:00
parent 136b3881c0
commit 79fc58f971
2 changed files with 9 additions and 26 deletions

View File

@@ -66,7 +66,7 @@ func newAWSArchiveChunkSource(ctx context.Context,
aRdr, err := newArchiveReaderFromFooter(ctx, &s3TableReaderAt{s3, name}, sz, footer, stats)
if err != nil {
return archiveChunkSource{}, err
return emptyChunkSource{}, err
}
return archiveChunkSource{"", aRdr}, nil
}

View File

@@ -33,7 +33,6 @@ import (
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3iface"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
@@ -84,30 +83,14 @@ func (s3p awsTablePersister) Open(ctx context.Context, name hash.Hash, chunkCoun
return cs, nil
}
var reqErr awserr.RequestFailure
if errors.As(err, &reqErr) {
if reqErr.Code() != "NoSuchKey" || reqErr.StatusCode() != 404 {
return emptyChunkSource{}, err
}
} else {
// Probably won't ever happen.
return emptyChunkSource{}, err
}
archiveKey := name.String() + ArchiveFileSuffix
e, err2 := s3p.Exists(ctx, archiveKey, chunkCount, stats)
if e && err2 == nil {
return newAWSArchiveChunkSource(
ctx,
&s3ObjectReader{s3: s3p.s3, bucket: s3p.bucket, readRl: s3p.rl, ns: s3p.ns},
s3p.limits,
archiveKey,
chunkCount,
s3p.q,
stats)
}
return emptyChunkSource{}, err
return newAWSArchiveChunkSource(
ctx,
&s3ObjectReader{s3: s3p.s3, bucket: s3p.bucket, readRl: s3p.rl, ns: s3p.ns},
s3p.limits,
name.String()+ArchiveFileSuffix,
chunkCount,
s3p.q,
stats)
}
func (s3p awsTablePersister) Exists(ctx context.Context, name string, _ uint32, stats *Stats) (bool, error) {