mirror of https://github.com/apache/jclouds.git
Creating a separate function to delete directories
Small refactoring to reuse some code.
This commit is contained in:
parent
b2be149946
commit
c6cb169dee
|
@ -177,6 +177,25 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr
|
||||||
return listing;
|
return listing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ListenableFuture<Void> deleteDirectory(final ListContainerOptions options,
|
||||||
|
final String containerName, final String dirName) {
|
||||||
|
ListenableFuture<Void> blobDelFuture;
|
||||||
|
|
||||||
|
if (options.isRecursive()) {
|
||||||
|
blobDelFuture = executorService.submit(new Callable<Void>() {
|
||||||
|
@Override
|
||||||
|
public Void call() {
|
||||||
|
blobStore.deleteDirectory(containerName, dirName);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
blobDelFuture = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return blobDelFuture;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the blobs from a given PageSet. The PageSet may contain blobs or
|
* Delete the blobs from a given PageSet. The PageSet may contain blobs or
|
||||||
* directories. If there are directories, they are expected to be empty.
|
* directories. If there are directories, they are expected to be empty.
|
||||||
|
@ -235,30 +254,11 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case FOLDER:
|
case FOLDER:
|
||||||
if (options.isRecursive()) {
|
blobDelFuture = deleteDirectory(options, containerName, fullPath);
|
||||||
blobDelFuture = executorService.submit(new Callable<Void>() {
|
|
||||||
@Override
|
|
||||||
public Void call() {
|
|
||||||
blobStore.deleteDirectory(containerName, fullPath);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
blobDelFuture = null;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case RELATIVE_PATH:
|
case RELATIVE_PATH:
|
||||||
if (options.isRecursive()) {
|
blobDelFuture = deleteDirectory(options, containerName,
|
||||||
blobDelFuture = executorService.submit(new Callable<Void>() {
|
md.getName());
|
||||||
@Override
|
|
||||||
public Void call() {
|
|
||||||
blobStore.deleteDirectory(containerName, md.getName());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
blobDelFuture = null;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case CONTAINER:
|
case CONTAINER:
|
||||||
throw new IllegalArgumentException("Container type not supported");
|
throw new IllegalArgumentException("Container type not supported");
|
||||||
|
|
Loading…
Reference in New Issue