Skip to content

Commit

Permalink
Remove deleted files from cache when performing a cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Tara Drwenski authored and tdrwenski committed Dec 6, 2023
1 parent f671aca commit 3b42c9a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cdm/core/src/main/java/ucar/nc2/util/cache/FileCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
package ucar.nc2.util.cache;

import java.nio.file.Files;
import java.nio.file.Paths;
import ucar.nc2.dataset.DatasetUrl;
import ucar.nc2.time.CalendarDate;
import ucar.nc2.time.CalendarDateFormatter;
Expand Down Expand Up @@ -697,13 +699,11 @@ public int compareTo(Tracker o) {
synchronized void cleanup(int maxElements) {

try {
/*
* int size = counter.get();
* int fsize = files.size();
* if (debug && (size != fsize)) {
* log.warn("FileCache " + name + " counter " + size + " doesnt match files().size=" + fsize);
* }
*/
for (CacheElement.CacheFile cacheFile : files.values()) {
if (!Files.exists(Paths.get(cacheFile.ncfile.getLocation()))) {
remove(cacheFile);
}
}

int size = files.size();
if (size <= minElements)
Expand Down

0 comments on commit 3b42c9a

Please sign in to comment.