public static boolean tryRecursiveDeleteEntriesOlderThan()

in src/main/java/com/googlesource/gerrit/plugins/events/fsstore/Fs.java [86:101]


  public static boolean tryRecursiveDeleteEntriesOlderThan(Path dir, FileTime expiry, int max) {
    try (DirectoryStream<Path> dirEntries = Files.newDirectoryStream(dir)) {
      for (Path path : dirEntries) {
        if (isOlderThan(path, expiry)) {
          if (max-- < 1) {
            return false;
          }
          tryRecursiveDelete(path);
        }
      }
    } catch (IOException e) { // Intent of 'try' function is to ignore these.
    } catch (DirectoryIteratorException e) {
      // dir was deleted by another actor, thus so were all its entries
    }
    return true;
  }