Skip to content
This repository has been archived by the owner on Jul 25, 2020. It is now read-only.

Commit

Permalink
Creating a separate function to delete directories
Browse files Browse the repository at this point in the history
Small refactoring to reuse some code.
  • Loading branch information
Shri Javadekar authored and demobox committed Apr 22, 2014
1 parent b2be149 commit c6cb169
Showing 1 changed file with 22 additions and 22 deletions.
Expand Up @@ -177,6 +177,25 @@ private PageSet<? extends StorageMetadata> getListing(
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
* directories. If there are directories, they are expected to be empty.
Expand Down Expand Up @@ -235,30 +254,11 @@ public Void call() {
});
break;
case FOLDER:
if (options.isRecursive()) {
blobDelFuture = executorService.submit(new Callable<Void>() {
@Override
public Void call() {
blobStore.deleteDirectory(containerName, fullPath);
return null;
}
});
} else {
blobDelFuture = null;
}
blobDelFuture = deleteDirectory(options, containerName, fullPath);
break;
case RELATIVE_PATH:
if (options.isRecursive()) {
blobDelFuture = executorService.submit(new Callable<Void>() {
@Override
public Void call() {
blobStore.deleteDirectory(containerName, md.getName());
return null;
}
});
} else {
blobDelFuture = null;
}
blobDelFuture = deleteDirectory(options, containerName,
md.getName());
break;
case CONTAINER:
throw new IllegalArgumentException("Container type not supported");
Expand Down

0 comments on commit c6cb169

Please sign in to comment.