diff src/goodjava/lucene/logging/LoggingIndexWriter.java @ 1473:6c6ce14db6a8

add goodjava.io
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 17 Apr 2020 13:56:57 -0600
parents 5e3870618377
children c7b86342857f
line wrap: on
line diff
--- a/src/goodjava/lucene/logging/LoggingIndexWriter.java	Fri Apr 17 11:16:38 2020 -0600
+++ b/src/goodjava/lucene/logging/LoggingIndexWriter.java	Fri Apr 17 13:56:57 2020 -0600
@@ -22,6 +22,7 @@
 import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
+import goodjava.io.IoUtils;
 import goodjava.lucene.api.GoodIndexWriter;
 import goodjava.lucene.api.LuceneIndexWriter;
 import goodjava.lucene.api.GoodCollector;
@@ -114,7 +115,7 @@
 		return new LogFile(file,"rwd");
 	}
 
-	private void deleteUnusedFiles() {
+	private void deleteUnusedFiles() throws IOException {
 		Set<String> used = new HashSet<String>();
 		used.add( index.getName() );
 		for( LogFile lf : logs ) {
@@ -127,14 +128,13 @@
 		}
 	}
 
-	private static void deleteFile(File file) {
+	private static void deleteFile(File file) throws IOException {
 		if( file.isDirectory() ) {
 			for( File f : file.listFiles() ) {
 				deleteFile(f);
 			}
 		}
-		if( !file.delete() )
-			throw new RuntimeException(file.getName());
+		IoUtils.delete(file);
 	}
 
 	private void writeIndex() throws IOException {