mirror of https://github.com/apache/jclouds.git
Force application/x-directory for directories
Paths created by Files.createParentDirs lack extended attributes and thus Content-Type for directories.
This commit is contained in:
parent
dabc0ab6a9
commit
56ad552344
|
@ -368,6 +368,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
|
||||||
builder.name(key);
|
builder.name(key);
|
||||||
File file = getFileForBlobKey(container, key);
|
File file = getFileForBlobKey(container, key);
|
||||||
ByteSource byteSource;
|
ByteSource byteSource;
|
||||||
|
boolean isDirectory = false;
|
||||||
|
|
||||||
if (getDirectoryBlobSuffix(key) != null) {
|
if (getDirectoryBlobSuffix(key) != null) {
|
||||||
if (!file.isDirectory()) {
|
if (!file.isDirectory()) {
|
||||||
|
@ -379,6 +380,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
|
||||||
}
|
}
|
||||||
logger.debug("%s - %s is a directory", container, key);
|
logger.debug("%s - %s is a directory", container, key);
|
||||||
byteSource = ByteSource.empty();
|
byteSource = ByteSource.empty();
|
||||||
|
isDirectory = true;
|
||||||
} else {
|
} else {
|
||||||
byteSource = Files.asByteSource(file);
|
byteSource = Files.asByteSource(file);
|
||||||
}
|
}
|
||||||
|
@ -387,7 +389,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
|
||||||
String contentDisposition = null;
|
String contentDisposition = null;
|
||||||
String contentEncoding = null;
|
String contentEncoding = null;
|
||||||
String contentLanguage = null;
|
String contentLanguage = null;
|
||||||
String contentType = null;
|
String contentType = isDirectory ? "application/x-directory" : null;
|
||||||
HashCode hashCode = null;
|
HashCode hashCode = null;
|
||||||
String eTag = null;
|
String eTag = null;
|
||||||
Date expires = null;
|
Date expires = null;
|
||||||
|
@ -403,9 +405,11 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
|
||||||
contentDisposition = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_DISPOSITION);
|
contentDisposition = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_DISPOSITION);
|
||||||
contentEncoding = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_ENCODING);
|
contentEncoding = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_ENCODING);
|
||||||
contentLanguage = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_LANGUAGE);
|
contentLanguage = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_LANGUAGE);
|
||||||
contentType = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_TYPE);
|
if (!isDirectory) {
|
||||||
if (contentType == null && autoDetectContentType) {
|
contentType = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_TYPE);
|
||||||
contentType = probeContentType(file.toPath());
|
if (contentType == null && autoDetectContentType) {
|
||||||
|
contentType = probeContentType(file.toPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (attributes.contains(XATTR_CONTENT_MD5)) {
|
if (attributes.contains(XATTR_CONTENT_MD5)) {
|
||||||
ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_CONTENT_MD5));
|
ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_CONTENT_MD5));
|
||||||
|
|
Loading…
Reference in New Issue