Skip to content

Commit

Permalink
blob/azblob: Restore As for List entry (#3188)
Browse files Browse the repository at this point in the history
  • Loading branch information
vangent authored Dec 2, 2022
1 parent e1a8e6f commit e942f3c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions blob/azureblob/azureblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
// azureblob exposes the following types for As:
// - Bucket: *container.Client
// - Error: *azcore.ReponseError. You can use bloberror.HasCode directly though.
// - ListObject: N/A.
// - ListObject: container.BlobItem for objects, none for "directories"
// - ListOptions.BeforeList: *container.ListBlobsHierarchyOptions
// - Reader: azblobblob.DownloadStreamResponse
// - Reader.BeforeRead: *azblob.DownloadStreamOptions
Expand Down Expand Up @@ -754,7 +754,11 @@ func (b *bucket) ListPaged(ctx context.Context, opts *driver.ListOptions) (*driv
MD5: blobInfo.Properties.ContentMD5,
IsDir: false,
AsFunc: func(i interface{}) bool {
return false
v, ok := i.(*container.BlobItem)
if ok {
*v = *blobInfo
}
return ok
},
})
}
Expand Down
10 changes: 10 additions & 0 deletions blob/azureblob/azureblob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,16 @@ func (verifyContentLanguage) ReaderCheck(r *blob.Reader) error {
}

func (verifyContentLanguage) ListObjectCheck(o *blob.ListObject) error {
if o.IsDir {
return nil
}
var item container.BlobItem
if !o.As(&item) {
return errors.New("ListObject.As for object returned false")
}
if got := *item.Properties.ContentLanguage; got != language {
return fmt.Errorf("got %q want %q", got, language)
}
return nil
}

Expand Down

0 comments on commit e942f3c

Please sign in to comment.