mirror of https://github.com/apache/jclouds.git
parent
5ca4827d1b
commit
18eb7f3d38
|
@ -334,6 +334,13 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
|
|||
ByteSource byteSource;
|
||||
|
||||
if (getDirectoryBlobSuffix(key) != null) {
|
||||
if (!file.isDirectory()) {
|
||||
// filesystem blobstore does not allow the existence of "file" and
|
||||
// "file/" and getDirectoryBlobSuffix normalizes "file/" to "file".
|
||||
// Therefore we need to return null when the normalized file is not
|
||||
// a directory.
|
||||
return null;
|
||||
}
|
||||
logger.debug("%s - %s is a directory", container, key);
|
||||
byteSource = ByteSource.empty();
|
||||
} else {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.jclouds.filesystem.strategy.internal;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.jclouds.filesystem.util.Utils.isMacOSX;
|
||||
import static org.jclouds.utils.TestUtils.NO_INVOCATIONS;
|
||||
import static org.jclouds.utils.TestUtils.SINGLE_NO_ARG_INVOCATION;
|
||||
|
@ -696,6 +697,42 @@ public class FilesystemStorageStrategyImplTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBlobTrailingSlash() throws Exception {
|
||||
String key = "key";
|
||||
ByteSource byteSource = randomByteSource().slice(0, 1024);
|
||||
Blob blob = new BlobBuilderImpl()
|
||||
.name(key)
|
||||
.payload(byteSource)
|
||||
.contentLength(byteSource.size())
|
||||
.build();
|
||||
storageStrategy.putBlob(CONTAINER_NAME, blob);
|
||||
|
||||
blob = storageStrategy.getBlob(CONTAINER_NAME, key);
|
||||
assertThat(blob).isNotNull();
|
||||
|
||||
blob = storageStrategy.getBlob(CONTAINER_NAME, key + "/");
|
||||
assertThat(blob).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPutBlobTrailingSlash() throws Exception {
|
||||
String key = "key";
|
||||
ByteSource byteSource = ByteSource.empty();
|
||||
Blob blob = new BlobBuilderImpl()
|
||||
.name(key + "/")
|
||||
.payload(byteSource)
|
||||
.contentLength(byteSource.size())
|
||||
.build();
|
||||
storageStrategy.putBlob(CONTAINER_NAME, blob);
|
||||
|
||||
blob = storageStrategy.getBlob(CONTAINER_NAME, key);
|
||||
assertThat(blob).isNull();
|
||||
|
||||
blob = storageStrategy.getBlob(CONTAINER_NAME, key + "/");
|
||||
assertThat(blob).isNotNull();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------- Private methods
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue