Skip to content

Commit

Permalink
Clear cached file immediately in loop
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmalloy committed Jul 10, 2024
1 parent 47c56ec commit 557a69e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/main/java/jasper/component/FileCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ public class FileCache {
public void clearDeleted(String origin) {
logger.info("{} Purging file cache", origin);
var start = Instant.now();
var deleteLater = new ArrayList<String>();
storage.visitStorage(origin, CACHE, id -> {
if (!refRepository.cacheExists(id)) deleteLater.add(id);
});
deleteLater.forEach(id -> {
try {
storage.delete(origin, CACHE, id);
} catch (IOException e) {
logger.error("Cannot delete file", e);
if (!refRepository.cacheExists(id)) {
try {
storage.delete(origin, CACHE, id);
} catch (IOException e) {
logger.error("Cannot delete file", e);
}
}
});
logger.info("{} Finished purging file cache in {}", origin, Duration.between(start, Instant.now()));
Expand Down

0 comments on commit 557a69e

Please sign in to comment.