Repository: jclouds Updated Branches: refs/heads/master 0fad16e07 -> 5edd5de38
make xattr work in docker volume when you bind a host volume into docker, java does not correctly detect that and checks the xattr support on the root fs instead of the host fs. The root fs often does not support xattr, so the check would fail even if the target really does support xattr. the fix is just try setting the xattrs anyway, and let them fail if there really isn't xattrs support Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/5edd5de3 Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/5edd5de3 Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/5edd5de3 Branch: refs/heads/master Commit: 5edd5de38c01f3a1ea962dd9f0a4bd6d060f32de Parents: 0fad16e Author: Ka-Hing Cheung <[email protected]> Authored: Fri Jan 9 14:11:46 2015 -0800 Committer: Andrew Gaul <[email protected]> Committed: Tue Jan 13 18:08:55 2015 -0800 ---------------------------------------------------------------------- .../internal/FilesystemStorageStrategyImpl.java | 30 +++++++++++--------- 1 file changed, 17 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds/blob/5edd5de3/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java ---------------------------------------------------------------------- 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 3790e16..1642527 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 @@ -17,7 +17,6 @@ package org.jclouds.filesystem.strategy.internal; import static java.nio.file.Files.getFileAttributeView; -import static java.nio.file.Files.getFileStore; import static java.nio.file.Files.readAttributes; import static com.google.common.base.Preconditions.checkNotNull; @@ -260,8 +259,8 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy { Date expires = null; ImmutableMap.Builder<String, String> userMetadata = ImmutableMap.builder(); - if (getFileStore(file.toPath()).supportsFileAttributeView(UserDefinedFileAttributeView.class)) { - UserDefinedFileAttributeView view = getFileAttributeView(path, UserDefinedFileAttributeView.class); + UserDefinedFileAttributeView view = getUserDefinedFileAttributeView(file.toPath()); + if (view != null) { Set<String> attributes = ImmutableSet.copyOf(view.list()); contentDisposition = readStringAttributeIfPresent(view, attributes, XATTR_CONTENT_DISPOSITION); @@ -346,8 +345,12 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy { UserDefinedFileAttributeView view = getUserDefinedFileAttributeView(outputPath); if (view != null) { - view.write(XATTR_CONTENT_MD5, ByteBuffer.wrap(DIRECTORY_MD5)); - writeCommonMetadataAttr(view, blob); + try { + view.write(XATTR_CONTENT_MD5, ByteBuffer.wrap(DIRECTORY_MD5)); + writeCommonMetadataAttr(view, blob); + } catch (IOException e) { + logger.debug("xattrs not supported on %s", outputPath); + } } else { logger.warn("xattr not supported on %s", blobKey); } @@ -380,10 +383,14 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy { } payload.getContentMetadata().setContentMD5(actualHashCode); - if (getFileStore(outputPath).supportsFileAttributeView(UserDefinedFileAttributeView.class)) { - UserDefinedFileAttributeView view = getFileAttributeView(outputPath, UserDefinedFileAttributeView.class); - view.write(XATTR_CONTENT_MD5, ByteBuffer.wrap(actualHashCode.asBytes())); - writeCommonMetadataAttr(view, blob); + UserDefinedFileAttributeView view = getUserDefinedFileAttributeView(outputPath); + if (view != null) { + try { + view.write(XATTR_CONTENT_MD5, ByteBuffer.wrap(actualHashCode.asBytes())); + writeCommonMetadataAttr(view, blob); + } catch (IOException e) { + logger.debug("xattrs not supported on %s", outputPath); + } } return base16().lowerCase().encode(actualHashCode.asBytes()); } catch (IOException ex) { @@ -526,10 +533,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy { } private UserDefinedFileAttributeView getUserDefinedFileAttributeView(Path path) throws IOException { - if (getFileStore(path).supportsFileAttributeView(UserDefinedFileAttributeView.class)) { - return getFileAttributeView(path, UserDefinedFileAttributeView.class); - } - return null; + return getFileAttributeView(path, UserDefinedFileAttributeView.class); } /**
