diff --git a/azblob/list.go b/azblob/list.go index 48f845c..bda4796 100644 --- a/azblob/list.go +++ b/azblob/list.go @@ -13,15 +13,28 @@ import ( // Count counts the number of blobs filtered by the given tags filter func (azp *Storer) Count(ctx context.Context, tagsFilter string, opts ...Option) (int64, error) { - - logger.Sugar.Debugf("Count") - - r, err := azp.FilteredList(ctx, tagsFilter, opts...) - if err != nil { - return 0, err - } - - return int64(len(r.Items)), nil + log := logger.Sugar.FromContext(ctx) + defer log.Close() + + log.Debugf("Count") + + var count int64 + var m string + opts = append(opts, WithListMarker(&m)) + + for { + r, err := azp.FilteredList(ctx, tagsFilter, opts...) + if err != nil { + return 0, err + } + count += int64(len(r.Items)) + log.Debugf("Count %d (%v)", count, r.Marker) + if r.Marker == nil { + break + } + } + log.Debugf("Count %d", count) + return count, nil } type FilterResponse struct {