sukiand commented on code in PR #12126: URL: https://github.com/apache/lucene/pull/12126#discussion_r1105037958
########## lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java: ########## @@ -225,24 +222,18 @@ public IndexFileDeleter( // Now delete anything with ref count at 0. These are // presumably abandoned files eg due to crash of // IndexWriter. - Set<String> toDelete = new HashSet<>(); - for (Map.Entry<String, RefCount> entry : refCounts.entrySet()) { - RefCount rc = entry.getValue(); - final String fileName = entry.getKey(); - if (0 == rc.count) { - // A segments_N file should never have ref count 0 on init: - if (fileName.startsWith(IndexFileNames.SEGMENTS)) { - throw new IllegalStateException( - "file \"" + fileName + "\" has refCount=0, which should never happen on init"); - } - if (infoStream.isEnabled("IFD")) { - infoStream.message("IFD", "init: removing unreferenced file \"" + fileName + "\""); - } - toDelete.add(fileName); + Set<String> toDelete = fileDeleter.getUnrefedFiles(); + for (String fileName : toDelete) { + if (fileName.startsWith(IndexFileNames.SEGMENTS)) { + throw new IllegalStateException( + "file \"" + fileName + "\" has refCount=0, which should never happen on init"); + } + if (infoStream.isEnabled("IFD")) { + infoStream.message("IFD", "init: removing unreferenced file \"" + fileName + "\""); } } - deleteFiles(toDelete); + fileDeleter.deleteFilesIfNoRef(toDelete); Review Comment: we get toDelete from `fileDeleter` as well. should this part of code be encaptulated into `fileDeleter` as a whole. like call fileDeleter.clean() or sth. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org