void (@NotNull List<Path> existingHistoryFiles) { Set<String> existingHistoryFilenames = ContainerUtil.map2Set(existingHistoryFiles, TerminalCommandHistoryManager::getFilename); long allowed = now() - TimeUnit.DAYS.toMillis(30); List<String> toRemove = new ArrayList<>(); for (CommandHistoryFileInfo info : myMap.values()) { if (info.myAccessTime <= allowed || !existingHistoryFilenames.contains(info.myFilename)) { toRemove.add(info.myFilename); } } for (String filename : existingHistoryFilenames) { if (!myMap.containsKey(filename)) { toRemove.add(filename); } } deleteHistoryFiles(toRemove, "outdated sessions"); }