diff --git a/azblob/list.go b/azblob/list.go index 48f845c..8d9d000 100644 --- a/azblob/list.go +++ b/azblob/list.go @@ -16,12 +16,23 @@ func (azp *Storer) Count(ctx context.Context, tagsFilter string, opts ...Option) logger.Sugar.Debugf("Count") - r, err := azp.FilteredList(ctx, tagsFilter, opts...) - if err != nil { - return 0, err - } - - return int64(len(r.Items)), nil + 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)) + logger.Sugar.Debugf("Count %d (%v)", count, r.Marker) + if r.Marker == nil { + break + } + } + logger.Sugar.Debugf("Count %d", count) + return count, nil } type FilterResponse struct { diff --git a/azblob/logger.go b/azblob/logger.go new file mode 100644 index 0000000..15db966 --- /dev/null +++ b/azblob/logger.go @@ -0,0 +1,11 @@ +package azbus + +import ( + "github.com/datatrails/go-datatrails-common/logger" +) + +const ( + DebugLevel = logger.DebugLevel +) + +type Logger = logger.Logger diff --git a/azblob/storer.go b/azblob/storer.go index 51822fd..8aa582a 100644 --- a/azblob/storer.go +++ b/azblob/storer.go @@ -27,6 +27,8 @@ type Storer struct { containerURL string containerClient *ContainerClient serviceClient *ServiceClient + + log Logger } // New returns new az blob read/write object