You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2018/01/09 20:47:32 UTC
jclouds git commit: Propagate access denied when creating container
Repository: jclouds
Updated Branches:
refs/heads/master 3877303ed -> 52c92a9eb
Propagate access denied when creating container
Previously this method only reported whether it created a container or
not and callers could not determine whether there was an error or if
the container already existed. References gaul/s3proxy#122.
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/52c92a9e
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/52c92a9e
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/52c92a9e
Branch: refs/heads/master
Commit: 52c92a9eb5afd55c17a228235b6a16640d0543ad
Parents: 3877303
Author: Andrew Gaul <ga...@apache.org>
Authored: Tue Jan 9 12:44:24 2018 -0800
Committer: Andrew Gaul <ga...@apache.org>
Committed: Tue Jan 9 12:44:24 2018 -0800
----------------------------------------------------------------------
.../internal/FilesystemStorageStrategyImpl.java | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/52c92a9e/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 a7b27df..728958c 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
@@ -19,6 +19,7 @@ package org.jclouds.filesystem.strategy.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.io.BaseEncoding.base16;
+import static java.nio.file.Files.createDirectories;
import static java.nio.file.Files.getFileAttributeView;
import static java.nio.file.Files.getPosixFilePermissions;
import static java.nio.file.Files.probeContentType;
@@ -36,6 +37,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
+import java.nio.file.AccessDeniedException;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
@@ -75,6 +77,7 @@ import org.jclouds.filesystem.util.Utils;
import org.jclouds.io.ContentMetadata;
import org.jclouds.io.Payload;
import org.jclouds.logging.Logger;
+import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.annotations.ParamValidators;
import com.google.common.base.Function;
@@ -908,8 +911,15 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
}
File directoryToCreate = new File(directoryFullName);
- boolean result = directoryToCreate.mkdirs();
- return result;
+ try {
+ createDirectories(directoryToCreate.toPath());
+ } catch (AccessDeniedException ade) {
+ throw new AuthorizationException(ade);
+ } catch (IOException ioe) {
+ logger.debug("Could not create directory: %s", ioe.getMessage());
+ return false;
+ }
+ return true;
}
/** Read the String representation of filesystem attribute, or return null if not present. */