JCLOUDS-930: LocalBlobStore -- marker regression.

We should not append a "/" to the marker when returning list results
in the case of directories (RELATIVE_PATH), as the names will already
include the delimiter.

Added a jclouds test to catch such regressions in the local store in
the future.
This commit is contained in:
Timur Alperovich 2015-06-30 08:43:34 -07:00
parent 8c9344b501
commit aade18b76d
2 changed files with 20 additions and 3 deletions

View File

@ -297,9 +297,6 @@ public final class LocalBlobStore implements BlobStore {
// Partial listing
lastElement = contents.last();
marker = lastElement.getName();
if (lastElement.getType() == StorageType.RELATIVE_PATH) {
marker += "/";
}
}
}

View File

@ -23,6 +23,7 @@ import com.google.inject.Injector;
import org.jclouds.ContextBuilder;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.domain.PageSet;
import org.jclouds.blobstore.domain.StorageMetadata;
import org.jclouds.blobstore.domain.StorageType;
import org.jclouds.blobstore.options.ListContainerOptions;
@ -125,4 +126,23 @@ public class ListContainerTest {
assertThat(results).hasSize(1);
assertThat(Iterables.get(results, 0).getName()).isEqualTo(directory + '/');
}
public void testListMarkers() {
String containerName = "testListMarkers";
blobStore.createContainerInLocation(null, containerName);
blobStore.putBlob(containerName, blobStore.blobBuilder("abc").payload("").build());
blobStore.putBlob(containerName, blobStore.blobBuilder("foo/bar").payload("").build());
blobStore.putBlob(containerName, blobStore.blobBuilder("foo/baz").payload("").build());
blobStore.putBlob(containerName, blobStore.blobBuilder("qux").payload("").build());
PageSet<? extends StorageMetadata> results = blobStore.list(
containerName, ListContainerOptions.Builder.maxResults(1));
assertThat(results.getNextMarker()).isEqualTo("abc");
results = blobStore.list(containerName,
ListContainerOptions.Builder.maxResults(1).afterMarker(results.getNextMarker()));
assertThat(results.getNextMarker()).isEqualTo("foo/");
results = blobStore.list(containerName,
ListContainerOptions.Builder.maxResults(1).afterMarker(results.getNextMarker()));
assertThat(results.getNextMarker()).isEqualTo(null);
}
}