Skip to content

Commit

Permalink
Replace objstore.Exists function calls with bkt.Exists (#2284)
Browse files Browse the repository at this point in the history
Signed-off-by: khyatisoneji <khyatisoneji5@gmail.com>
  • Loading branch information
khyatisoneji committed Mar 18, 2020
1 parent 5cb3c87 commit 2d7b214
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cmd/thanos/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ func generateIndexCacheFile(
cachePath := filepath.Join(bdir, block.IndexCacheFilename)
cache := path.Join(meta.ULID.String(), block.IndexCacheFilename)

ok, err := objstore.Exists(ctx, bkt, cache)
ok, err := bkt.Exists(ctx, cache)
if ok {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func cleanUp(logger log.Logger, bkt objstore.Bucket, id ulid.ULID, err error) er
// MarkForDeletion creates a file which stores information about when the block was marked for deletion.
func MarkForDeletion(ctx context.Context, logger log.Logger, bkt objstore.Bucket, id ulid.ULID) error {
deletionMarkFile := path.Join(id.String(), metadata.DeletionMarkFilename)
deletionMarkExists, err := objstore.Exists(ctx, bkt, deletionMarkFile)
deletionMarkExists, err := bkt.Exists(ctx, deletionMarkFile)
if err != nil {
return errors.Wrapf(err, "check exists %s in bucket", deletionMarkFile)
}
Expand Down
17 changes: 0 additions & 17 deletions pkg/objstore/objstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,6 @@ func DownloadDir(ctx context.Context, logger log.Logger, bkt BucketReader, src,
return nil
}

// Exists returns true, if file exists, otherwise false and nil error if presence IsObjNotFoundErr, otherwise false with
// returning error.
func Exists(ctx context.Context, bkt Bucket, src string) (bool, error) {
rc, err := bkt.Get(ctx, src)
if rc != nil {
_ = rc.Close()
}
if err != nil {
if bkt.IsObjNotFoundErr(err) {
return false, nil
}
return false, errors.Wrap(err, "stat object")
}

return true, nil
}

const (
iterOp = "iter"
sizeOp = "objectsize"
Expand Down

0 comments on commit 2d7b214

Please sign in to comment.