Skip to content

Commit

Permalink
Revert "s3: stat object instead of empty read"
Browse files Browse the repository at this point in the history
This reverts commit f735308.
  • Loading branch information
Ake van der Meer committed Oct 10, 2024
1 parent 8897e65 commit 48de08a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions providers/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"strings"
"testing"

"github.com/efficientgo/core/logerrcapture"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/minio/minio-go/v7"
Expand Down Expand Up @@ -437,12 +438,21 @@ func (b *Bucket) getRange(ctx context.Context, name string, off, length int64) (
return nil, err
}
}
r, err := b.client.GetObject(ctx, b.name, name, *opts)
if err != nil {
return nil, err
}

// StatObject to see if the object exists and we have permissions to read it
if _, err := b.client.StatObject(ctx, b.name, name, *opts); err != nil {
// NotFoundObject error is revealed only after first Read. This does the initial GetRequest. Prefetch this here
// for convenience.
if _, err := r.Read(nil); err != nil {
defer logerrcapture.Do(b.logger, r.Close, "s3 get range obj close")

// First GET Object request error.
return nil, err
}
return b.client.GetObject(ctx, b.name, name, *opts)

return r, nil
}

// Get returns a reader for the given object name.
Expand Down

0 comments on commit 48de08a

Please sign in to comment.