Skip to content

Commit

Permalink
chore: add ObjectExistsWithSize to respect the interface
Browse files Browse the repository at this point in the history
new method was added in grafana#14268
  • Loading branch information
JoaoBraveCoding committed Sep 30, 2024
1 parent 3fef0bf commit 46b9f73
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/storage/chunk/client/gcp/gcs_thanos_object_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ func (s *GCSThanosObjectClient) ObjectExists(ctx context.Context, objectKey stri
return s.client.Exists(ctx, objectKey)
}

// ObjectExistsWithSize checks if a given objectKey exists and it's size in the GCS bucket
func (s *GCSThanosObjectClient) ObjectExistsWithSize(ctx context.Context, objectKey string) (bool, int64, error) {
_, err := s.client.Get(ctx, objectKey)
if err != nil {
return false, 0, err
}

attr, err := s.client.Attributes(ctx, objectKey)
if err != nil {
return true, 0, nil
}

return true, attr.Size, nil
}

// PutObject puts the specified bytes into the configured GCS bucket at the provided key
func (s *GCSThanosObjectClient) PutObject(ctx context.Context, objectKey string, object io.Reader) error {
return s.client.Upload(ctx, objectKey, object)
Expand Down

0 comments on commit 46b9f73

Please sign in to comment.