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 e8702a0d0b..ed7ff48e98 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java @@ -353,7 +353,7 @@ public final class LocalBlobStore implements BlobStore { transform(contents, new CommonPrefixes(prefix, delimiter))); commonPrefixes.remove(CommonPrefixes.NO_PREFIX); - contents = newTreeSet(filter(contents, new DelimiterFilter(prefix, delimiter, commonPrefixes))); + contents = newTreeSet(filter(contents, new DelimiterFilter(prefix, delimiter))); for (String o : commonPrefixes) { MutableStorageMetadata md = new MutableStorageMetadataImpl(); @@ -457,20 +457,15 @@ public final class LocalBlobStore implements BlobStore { private static class DelimiterFilter implements Predicate { private final String prefix; private final String delimiter; - private final Set commonPrefixes; - public DelimiterFilter(String prefix, String delimiter, final Set commonPrefixes) { + public DelimiterFilter(String prefix, String delimiter) { this.prefix = prefix; this.delimiter = delimiter; - this.commonPrefixes = commonPrefixes; } public boolean apply(StorageMetadata metadata) { String name = metadata.getName(); if (prefix == null || prefix.isEmpty()) { - if (commonPrefixes.contains(name)) { - return false; - } return name.indexOf(delimiter) == -1; } String prefixMatch; @@ -482,7 +477,7 @@ public final class LocalBlobStore implements BlobStore { } if (name.matches(prefixMatch)) { String unprefixedName = name.replaceFirst(prefix, ""); - if (unprefixedName.equals("") || commonPrefixes.contains(unprefixedName)) { + if (unprefixedName.equals("")) { // we are the prefix in this case, return false return false; } diff --git a/blobstore/src/test/clojure/org/jclouds/blobstore2_test.clj b/blobstore/src/test/clojure/org/jclouds/blobstore2_test.clj index 8ea5b2a1a6..055e155449 100644 --- a/blobstore/src/test/clojure/org/jclouds/blobstore2_test.clj +++ b/blobstore/src/test/clojure/org/jclouds/blobstore2_test.clj @@ -73,11 +73,14 @@ (create-directory blobstore-stub "container" "dir") (is (put-blob blobstore-stub "container" (blob "dir/blob2" :payload "blob2"))) - (is (= 3 (count-blobs blobstore-stub "container"))) - (is (= 3 (count (blobs blobstore-stub "container")))) - (is (= 4 (count (blobs blobstore-stub "container" :recursive true)))) - (is (= 3 (count (blobs blobstore-stub "container" :with-details true)))) - (is (= 1 (count (blobs blobstore-stub "container" :in-directory "dir"))))) + (is (put-blob blobstore-stub "container" + (blob "dir/blob3" :payload "blob3"))) + (is (= 4 (count-blobs blobstore-stub "container"))) + (is (= 4 (count (blobs blobstore-stub "container")))) + (is (= 5 (count (blobs blobstore-stub "container" :recursive true)))) + (is (= 4 (count (blobs blobstore-stub "container" :with-details true)))) + ;; jclouds will list dir and dir/ + (is (= 2 (count (blobs blobstore-stub "container" :in-directory "dir"))))) (deftest large-container-list-test (let [container-name "test" 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 a71429adfe..acef128242 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 @@ -123,8 +123,9 @@ public class ListContainerTest { blobStore.putBlob(containerName, blobStore.blobBuilder(directory + "/foo").payload("").build()); blobStore.putBlob(containerName, blobStore.blobBuilder(directory + "/bar").payload("").build()); Iterable results = concatter.execute(containerName, ListContainerOptions.NONE); - assertThat(results).hasSize(1); - assertThat(Iterables.get(results, 0).getName()).isEqualTo(directory + '/'); + assertThat(results).hasSize(2); + assertThat(Iterables.get(results, 0).getName()).isEqualTo(directory); + assertThat(Iterables.get(results, 1).getName()).isEqualTo(directory + '/'); } public void testListMarkers() { @@ -153,8 +154,9 @@ public class ListContainerTest { blobStore.createDirectory(containerName, "dir/dir"); PageSet results = blobStore.list(containerName); - assertThat(results.size()).isEqualTo(1); - assertThat(Iterables.get(results, 0).getName()).isEqualTo("dir/"); + assertThat(results.size()).isEqualTo(2); + assertThat(Iterables.get(results, 0).getName()).isEqualTo("dir"); + assertThat(Iterables.get(results, 1).getName()).isEqualTo("dir/"); results = blobStore.list(containerName, ListContainerOptions.Builder.inDirectory("dir")); assertThat(results.size()).isEqualTo(1); @@ -162,7 +164,8 @@ public class ListContainerTest { blobStore.putBlob(containerName, blobStore.blobBuilder("dir/dir/blob").payload("").build()); results = blobStore.list(containerName, ListContainerOptions.Builder.inDirectory("dir")); - assertThat(results.size()).isEqualTo(1); - assertThat(Iterables.get(results, 0).getName()).isEqualTo("dir/dir/"); + assertThat(results.size()).isEqualTo(2); + assertThat(Iterables.get(results, 0).getName()).isEqualTo("dir/dir"); + assertThat(Iterables.get(results, 1).getName()).isEqualTo("dir/dir/"); } }