fix non-recursive list of dir with empty prefix

This commit is contained in:
Ka-Hing Cheung 2015-02-23 17:52:42 -08:00
parent a56fa3926a
commit a2ee7341e3
2 changed files with 19 additions and 1 deletions

View File

@ -524,6 +524,24 @@ public class FilesystemBlobStoreTest {
checkForContainerContent(CONTAINER_NAME, dirs);
}
@Test(dataProvider = "ignoreOnMacOSX")
public void testListDirectoryBlobsS3FS() {
blobStore.createContainerInLocation(null, CONTAINER_NAME);
checkForContainerContent(CONTAINER_NAME, null);
String d = TestUtils.createRandomBlobKey("directory-", "");
blobStore.putBlob(CONTAINER_NAME, createDirBlob(d + File.separator));
assertTrue(blobStore.blobExists(CONTAINER_NAME, d + File.separator));
ListContainerOptions options = ListContainerOptions.Builder
.withDetails()
.inDirectory("");
PageSet<? extends StorageMetadata> res = blobStore.list(CONTAINER_NAME, options);
assertTrue(res.size() == 1);
assertEquals(res.iterator().next().getName(), d);
}
/**
* Test of putBlob method with a complex key, with path in the filename, eg
* picture/filename.jpg

View File

@ -261,7 +261,7 @@ public final class LocalBlobStore implements BlobStore {
for (String o : commonPrefixes) {
MutableStorageMetadata md = new MutableStorageMetadataImpl();
md.setType(StorageType.RELATIVE_PATH);
if (prefix != null) {
if (prefix != null && !prefix.isEmpty()) {
if (!prefix.endsWith(delimiter)) {
o = prefix + delimiter + o;
} else {