Skip to content

Commit 4fa41b6

Browse files
committed
delete the whole directory if we can
1 parent 317f7a4 commit 4fa41b6

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/main/java/com/lowtuna/jsonblob/core/BlobCleanupJob.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public void run() {
3636
for(String dataDirPath: dataDirs) {
3737
File dir = new File(dataDirPath);
3838
if (dir.listFiles().length == 0) {
39+
log.debug("Deleting {} because there are no files in it", dir);
3940
dir.delete();
4041
}
4142

src/main/java/com/lowtuna/jsonblob/core/DataDirectoryCleanupJob.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ public DateTime apply(@Nullable String input) {
7070
return;
7171
}
7272

73+
if (toRemove.size() == blobs.size()) {
74+
log.info("All {} files in {} should be deleted, so we'll delete the directory", toRemove.size(), dir);
75+
dir.delete();
76+
log.info("{} was deleted", dir);
77+
}
78+
7379
log.debug("Submitting BulkBlobDeleteJobs for {} blobs in {}", toRemove.size(), dir);
7480
List<List<String>> subSets = Lists.partition(Lists.newArrayList(toRemove.keySet()), 100);
7581
subSets.parallelStream().forEach(list -> executorService.submit(new BulkBlobDeleteJob(Sets.newHashSet(list), fileSystemJsonBlobManager, deleteEnabled)));

0 commit comments

Comments
 (0)