Skip to content

Commit 7d69099

Browse files
authored
blob/azblob: Update to latest, and restore As for dirlist (#3191)
1 parent e942f3c commit 7d69099

File tree

86 files changed

+2836
-6721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2836
-6721
lines changed

blob/azureblob/azureblob.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
// azureblob exposes the following types for As:
7878
// - Bucket: *container.Client
7979
// - Error: *azcore.ReponseError. You can use bloberror.HasCode directly though.
80-
// - ListObject: container.BlobItem for objects, none for "directories"
80+
// - ListObject: container.BlobItem for objects, container.BlobPrefix for "directories"
8181
// - ListOptions.BeforeList: *container.ListBlobsHierarchyOptions
8282
// - Reader: azblobblob.DownloadStreamResponse
8383
// - Reader.BeforeRead: *azblob.DownloadStreamOptions
@@ -742,7 +742,11 @@ func (b *bucket) ListPaged(ctx context.Context, opts *driver.ListOptions) (*driv
742742
Size: 0,
743743
IsDir: true,
744744
AsFunc: func(i interface{}) bool {
745-
return false
745+
v, ok := i.(*container.BlobPrefix)
746+
if ok {
747+
*v = *blobPrefix
748+
}
749+
return ok
746750
}})
747751
}
748752
for _, blobInfo := range segment.BlobItems {
@@ -759,8 +763,7 @@ func (b *bucket) ListPaged(ctx context.Context, opts *driver.ListOptions) (*driv
759763
*v = *blobInfo
760764
}
761765
return ok
762-
},
763-
})
766+
}})
764767
}
765768
if resp.NextMarker != nil {
766769
page.NextPageToken = []byte(*resp.NextMarker)
@@ -883,7 +886,7 @@ func (b *bucket) NewTypedWriter(ctx context.Context, key string, contentType str
883886
md[e] = escape.URLEscape(v)
884887
}
885888
uploadOpts := &azblob.UploadStreamOptions{
886-
BlockSize: opts.BufferSize,
889+
BlockSize: int64(opts.BufferSize),
887890
Concurrency: opts.MaxConcurrency,
888891
Metadata: md,
889892
HTTPHeaders: &azblobblob.HTTPHeaders{

blob/azureblob/azureblob_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ func (verifyContentLanguage) ReaderCheck(r *blob.Reader) error {
247247

248248
func (verifyContentLanguage) ListObjectCheck(o *blob.ListObject) error {
249249
if o.IsDir {
250+
var prefix container.BlobPrefix
251+
if !o.As(&prefix) {
252+
return errors.New("ListObject.As for dir returned false")
253+
}
250254
return nil
251255
}
252256
var item container.BlobItem

0 commit comments

Comments
 (0)