Skip to content

Commit

Permalink
dont break interface
Browse files Browse the repository at this point in the history
  • Loading branch information
KastenMike committed Aug 29, 2024
1 parent 49ffdb2 commit 4402e37
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
24 changes: 18 additions & 6 deletions repo/blob/gcs/gcs_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,26 @@ func (gcs *gcsStorage) getBlobWithVersion(ctx context.Context, b blob.ID, versio
return blob.EnsureLengthExactly(output.Length(), length)
}

func (gcs *gcsStorage) GetMetadata(oi *storage.ObjectAttrs) blob.Metadata {
func (gcs *gcsStorage) GetMetadata(ctx context.Context, b blob.ID) (blob.Metadata, error) {
objName := gcs.getObjectNameString(b)
obj := gcs.bucket.Object(objName)

attrs, err := obj.Attrs(ctx)
if err != nil {
return blob.Metadata{}, errors.Wrap(translateError(err), "Attrs")
}

return gcs.getBlobMeta(attrs), nil
}

func (gcs *gcsStorage) getBlobMeta(attrs *storage.ObjectAttrs) blob.Metadata {
bm := blob.Metadata{
BlobID: toBlobID(oi.Name, gcs.Prefix),
Length: oi.Size,
Timestamp: oi.Created,
BlobID: toBlobID(attrs.Name, gcs.Prefix),
Length: attrs.Size,
Timestamp: attrs.Created,
}

if t, ok := timestampmeta.FromValue(oi.Metadata[timeMapKey]); ok {
if t, ok := timestampmeta.FromValue(attrs.Metadata[timeMapKey]); ok {
bm.Timestamp = t
}
return bm
Expand Down Expand Up @@ -203,7 +215,7 @@ func (gcs *gcsStorage) ListBlobs(ctx context.Context, prefix blob.ID, callback f

oa, err := lst.Next()
for err == nil {
bm := gcs.GetMetadata(oa)
bm := gcs.getBlobMeta(oa)

if cberr := callback(bm); cberr != nil {
return cberr
Expand Down
6 changes: 1 addition & 5 deletions repo/blob/gcs/gcs_versioned.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ func toBlobID(blobName, prefix string) blob.ID {
}

func (gcs *gcsPointInTimeStorage) getVersionMetadata(prefix string, oi *storage.ObjectAttrs) versionMetadata {
bm := blob.Metadata{
BlobID: toBlobID(oi.Name, prefix),
Length: oi.Size,
Timestamp: oi.Created,
}
bm := gcs.getBlobMeta(oi)
return versionMetadata{
Metadata: bm,
IsDeleteMarker: !oi.Deleted.IsZero() && (gcs.PointInTime == nil || oi.Deleted.Before(*gcs.PointInTime)),
Expand Down

0 comments on commit 4402e37

Please sign in to comment.