in Source/NuGetGallery.Operations/Util.cs [291:330]
public static IList<CloudBlockBlob> CollectBlobs(Logger log, CloudBlobContainer container, string prefix, Func<CloudBlockBlob, bool> condition = null, int? countEstimate = null)
{
List<CloudBlockBlob> list;
if (countEstimate.HasValue)
{
list = new List<CloudBlockBlob>(countEstimate.Value);
}
else
{
list = new List<CloudBlockBlob>();
}
BlobContinuationToken token = null;
do
{
var segment = container.ListBlobsSegmented(
prefix,
useFlatBlobListing: true,
blobListingDetails: BlobListingDetails.Copy,
maxResults: null,
currentToken: token,
options: new BlobRequestOptions(),
operationContext: new OperationContext());
var oldCount = list.Count;
int total = 0;
foreach (var blob in segment.Results.OfType<CloudBlockBlob>())
{
if (condition == null || condition(blob))
{
list.Add(blob);
}
total++;
}
log.Info("Matched {0}/{1} blobs in current segment. Found {2} blobs so far...", list.Count - oldCount, total, list.Count);
token = segment.ContinuationToken;
} while (token != null);
return list;
}