Skip to content

Commit 4527035

Browse files
committed
reuse the result
1 parent 4fb91b4 commit 4527035

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ public BlobCleanupProducer(Path dataDirectoryPath, Duration blobAccessTtl, Block
3434

3535
@Override
3636
protected boolean handleDirectory(File directory, int depth, Collection<Void> results) throws IOException {
37-
if (directory.listFiles() != null && directory.listFiles().length == 0) {
37+
File[] files = directory.listFiles();
38+
39+
if (files != null && files.length == 0) {
3840
if (directory.delete()) log.info("{} has no files, so it's being deleted", directory.getAbsolutePath());
3941
return false;
4042
}
4143

42-
if (directory.listFiles().length == 1) {
43-
if (directory.listFiles()[0].getName().startsWith(FileSystemJsonBlobManager.BLOB_METADATA_FILE_NAME)) {
44+
if (files.length == 1) {
45+
if (files[0].getName().startsWith(FileSystemJsonBlobManager.BLOB_METADATA_FILE_NAME)) {
4446
if (directory.delete()) log.info("{} has only a metadata file, so it's being deleted", directory.getAbsolutePath());
4547
return false;
4648
}
@@ -53,7 +55,7 @@ protected boolean handleDirectory(File directory, int depth, Collection<Void> re
5355
process = localDate.isBefore(LocalDate.now().minusDays(blobAccessTtl.toDays()));
5456
if (process) {
5557
log.info("Processing {} blobs for un-accessed blobs", directory.getAbsolutePath());
56-
for (File file: directory.listFiles()) {
58+
for (File file: files) {
5759
try {
5860
filesToProcess.put(file);
5961
} catch (InterruptedException e) {

0 commit comments

Comments
 (0)