From e59ccbff819ddbf5ffcf4a412ed9c75cd0ecef27 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Wed, 14 Nov 2018 14:42:30 -0800 Subject: [PATCH] Do not allow options in filesystem clearContainer This requires some additional logic to clean up empty directories. Test regression from 22ce5484a412bc06ef62995675c07e7a85f66bdf. --- .../strategy/internal/FilesystemStorageStrategyImpl.java | 6 +++--- .../integration/FilesystemContainerIntegrationTest.java | 5 +++++ 2 files changed, 8 insertions(+), 3 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 cf3b81bbed..b51124bc9b 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 @@ -16,6 +16,7 @@ */ package org.jclouds.filesystem.strategy.internal; +import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.io.BaseEncoding.base16; @@ -248,9 +249,8 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy { @Override public void clearContainer(String container, ListContainerOptions options) { filesystemContainerNameValidator.validate(container); - if (options.getDir() != null) { - container += denormalize("/" + options.getDir()); - } + // TODO: these require calling removeDirectoriesTreeOfBlobKey + checkArgument(options.getDir() == null || options.getPrefix() == null, "cannot specify directory or prefix"); try { File containerFile = openFolder(container); File[] children = containerFile.listFiles(); diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTest.java index 7dfdd3acf7..c9fee7356a 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTest.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTest.java @@ -193,4 +193,9 @@ public class FilesystemContainerIntegrationTest extends BaseContainerIntegration public void testSetContainerAccess() throws Exception { throw new SkipException("filesystem does not support anonymous access"); } + + @Override + public void testClearWithOptions() throws InterruptedException { + throw new SkipException("filesystem does not support clear with options"); + } }