This is an automated email from the ASF dual-hosted git repository.
gaul pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jclouds.git
The following commit(s) were added to refs/heads/master by this push:
new 56ad552 Force application/x-directory for directories
56ad552 is described below
commit 56ad5523447cbd6ed763b312f59de8e4b8a3b2bc
Author: Andrew Gaul <[email protected]>
AuthorDate: Tue Feb 2 22:56:51 2021 +0900
Force application/x-directory for directories
Paths created by Files.createParentDirs lack extended attributes and
thus Content-Type for directories.
---
.../strategy/internal/FilesystemStorageStrategyImpl.java | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git
a/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java
b/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java
index 1c438df..f34b3aa 100644
---
a/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java
+++
b/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java
@@ -368,6 +368,7 @@ public class FilesystemStorageStrategyImpl implements
LocalStorageStrategy {
builder.name(key);
File file = getFileForBlobKey(container, key);
ByteSource byteSource;
+ boolean isDirectory = false;
if (getDirectoryBlobSuffix(key) != null) {
if (!file.isDirectory()) {
@@ -379,6 +380,7 @@ public class FilesystemStorageStrategyImpl implements
LocalStorageStrategy {
}
logger.debug("%s - %s is a directory", container, key);
byteSource = ByteSource.empty();
+ isDirectory = true;
} else {
byteSource = Files.asByteSource(file);
}
@@ -387,7 +389,7 @@ public class FilesystemStorageStrategyImpl implements
LocalStorageStrategy {
String contentDisposition = null;
String contentEncoding = null;
String contentLanguage = null;
- String contentType = null;
+ String contentType = isDirectory ? "application/x-directory" : null;
HashCode hashCode = null;
String eTag = null;
Date expires = null;
@@ -403,9 +405,11 @@ public class FilesystemStorageStrategyImpl implements
LocalStorageStrategy {
contentDisposition = readStringAttributeIfPresent(view,
attributes, XATTR_CONTENT_DISPOSITION);
contentEncoding = readStringAttributeIfPresent(view,
attributes, XATTR_CONTENT_ENCODING);
contentLanguage = readStringAttributeIfPresent(view,
attributes, XATTR_CONTENT_LANGUAGE);
- contentType = readStringAttributeIfPresent(view, attributes,
XATTR_CONTENT_TYPE);
- if (contentType == null && autoDetectContentType) {
- contentType = probeContentType(file.toPath());
+ if (!isDirectory) {
+ contentType = readStringAttributeIfPresent(view, attributes,
XATTR_CONTENT_TYPE);
+ if (contentType == null && autoDetectContentType) {
+ contentType = probeContentType(file.toPath());
+ }
}
if (attributes.contains(XATTR_CONTENT_MD5)) {
ByteBuffer buf =
ByteBuffer.allocate(view.size(XATTR_CONTENT_MD5));