Pagination for listing LocalBlobStore MPU parts

This commit is contained in:
Andrew Gaul 2015-10-20 14:01:32 -07:00
parent 4829bbbd2c
commit e0c959c212
1 changed files with 13 additions and 7 deletions

View File

@ -829,14 +829,20 @@ public final class LocalBlobStore implements BlobStore {
@Override
public List<MultipartPart> listMultipartUpload(MultipartUpload mpu) {
ImmutableList.Builder<MultipartPart> parts = ImmutableList.builder();
PageSet<? extends StorageMetadata> pageSet = list(mpu.containerName(),
new ListContainerOptions().prefix(mpu.blobName() + "-").recursive());
// TODO: pagination
ListContainerOptions options =
new ListContainerOptions().prefix(mpu.blobName() + "-").recursive();
while (true) {
PageSet<? extends StorageMetadata> pageSet = list(mpu.containerName(), options);
for (StorageMetadata sm : pageSet) {
int partNumber = Integer.parseInt(sm.getName().substring((mpu.blobName() + "-").length()));
long partSize = -1; // TODO: could call getContentMetadata but did not above
parts.add(MultipartPart.create(partNumber, partSize, sm.getETag()));
}
if (pageSet.isEmpty() || pageSet.getNextMarker() == null) {
break;
}
options.afterMarker(pageSet.getNextMarker());
}
return parts.build();
}