diff --git a/src/main/java/ninja/Bucket.java b/src/main/java/ninja/Bucket.java index d5da3b8..bf329dc 100644 --- a/src/main/java/ninja/Bucket.java +++ b/src/main/java/ninja/Bucket.java @@ -136,22 +136,26 @@ public boolean exists() { *

* If the underlying directory already exists, nothing happens. * - * @return true if the folder for the bucket was created successfully and if it was missing before + * @return true if the folder for the bucket was created successfully or existed before, false else */ public boolean create() { - if (folder.exists() || !folder.mkdirs()) { + if (folder.exists()) { + return true; + } + + if (!folder.mkdirs()) { return false; } // having successfully created the folder, write the version marker writeVersion(); - return true; + return folder.isDirectory(); } /** * Deletes the bucket and all of its contents. * - * @return true if all files of the bucket and the bucket itself was deleted successfully, false otherwise. + * @return true if all files of the bucket and the bucket itself were deleted successfully, false else */ public boolean delete() { if (!folder.exists()) { @@ -278,26 +282,35 @@ public boolean isPrivate() { /** * Marks the bucket as only privately accessible, i.e. non-public. + * + * @return true if the bucket is now only privately accessible, false else */ - public void makePrivate() { + public boolean makePrivate() { if (publicMarker.exists()) { sirius.kernel.commons.Files.delete(publicMarker); publicAccessCache.put(getName(), false); } + + return !publicMarker.exists(); } /** * Marks the bucket as publicly accessible. + * + * @return true if the bucket is now publicly accessible, false else */ - public void makePublic() { + public boolean makePublic() { if (!publicMarker.exists()) { try { new FileOutputStream(publicMarker).close(); } catch (IOException e) { - throw Exceptions.handle(Storage.LOG, e); + Exceptions.handle(Storage.LOG, e); + return false; } } publicAccessCache.put(getName(), true); + + return publicMarker.exists(); } /**