changeset 1500:f01abd6d5858

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 10 May 2020 13:06:11 -0600
parents 22e15cf73040
children e66e3d50b289
files src/goodjava/lucene/backup/Backup.java src/goodjava/lucene/backup/BackupIndexWriter.java
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/goodjava/lucene/backup/Backup.java	Sat May 09 23:14:13 2020 -0600
+++ b/src/goodjava/lucene/backup/Backup.java	Sun May 10 13:06:11 2020 -0600
@@ -21,9 +21,11 @@
 	private static final Logger logger = LoggerFactory.getLogger(Backup.class);
 
 	private final File dir;
+	private final File index;
 
 	Backup(File dir) {
 		this.dir = dir;
+		this.index = new File(dir,"index");
 	}
 
 	synchronized void handle(RpcServer rpc,RpcCall call) {
@@ -91,7 +93,6 @@
 				logs.add( new LogFile(f) );
 			}
 			if( complete ) {
-				File index = new File(dir,"index");
 				LoggingIndexWriter.writeIndex(logs,index);
 				logger.info("write index");
 			}
--- a/src/goodjava/lucene/backup/BackupIndexWriter.java	Sat May 09 23:14:13 2020 -0600
+++ b/src/goodjava/lucene/backup/BackupIndexWriter.java	Sun May 10 13:06:11 2020 -0600
@@ -67,9 +67,7 @@
 		List<LogFile> logs = new ArrayList<LogFile>();
 		synchronized(this) {
 			isSyncPending = false;
-			for( File f : dir.listFiles() ) {
-				IoUtils.delete(f);
-			}
+			clearDir();
 			for( LogFile log : this.logs ) {
 				File f = new File(dir,log.file.getName());
 				IoUtils.link(log.file,f);
@@ -118,6 +116,13 @@
 			}
 			rpc.close();
 		}
+		clearDir();
+	}
+
+	private void clearDir() throws IOException {
+		for( File f : dir.listFiles() ) {
+			IoUtils.delete(f);
+		}
 	}
 
 	static RpcClient rpcClient(String backupDomain) throws IOException {