From aade18b76d9c78be2a207e54722814907b191bed Mon Sep 17 00:00:00 2001 From: Timur Alperovich Date: Tue, 30 Jun 2015 08:43:34 -0700 Subject: [PATCH] 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. --- .../blobstore/config/LocalBlobStore.java | 3 --- .../strategy/internal/ListContainerTest.java | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java index a244a4b1df..278f6d88b6 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java @@ -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 += "/"; - } } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/ListContainerTest.java b/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/ListContainerTest.java index 435df30405..27aa8e33aa 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/ListContainerTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/ListContainerTest.java @@ -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 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); + } }