diff src/goodjava/lucene/backup/Backup.java @ 1512:31b543826ca9

lucene.backup login
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 23 May 2020 19:01:57 -0600
parents 0ba144491a42
children 736ec76bbf42
line wrap: on
line diff
--- a/src/goodjava/lucene/backup/Backup.java	Fri May 22 19:10:14 2020 -0600
+++ b/src/goodjava/lucene/backup/Backup.java	Sat May 23 19:01:57 2020 -0600
@@ -13,6 +13,7 @@
 import goodjava.rpc.RpcServer;
 import goodjava.rpc.RpcCall;
 import goodjava.rpc.RpcResult;
+import goodjava.rpc.RpcException;
 import goodjava.logging.Logger;
 import goodjava.logging.LoggerFactory;
 import goodjava.lucene.logging.LogFile;
@@ -52,7 +53,7 @@
 		if( call.cmd.equals("check") ) {
 			// nothing
 		} else if( call.cmd.equals("add") || call.cmd.equals("append")  ) {
-			fileName = (String)call.args[2];
+			fileName = (String)call.args[1];
 			File f = new File(dir,fileName);
 			if( call.cmd.equals("add") )
 				IoUtils.delete(f);
@@ -61,11 +62,14 @@
 			IoUtils.copyAll(call.in,out);
 			out.commit();
 			out.close();
-			logger.info(call.cmd+" "+fileName+" "+call.lenIn);
-		} else
-			throw new RuntimeException("cmd "+call.cmd);
-		List logInfo = (List)call.args[1];
-		logger.info("check "+logInfo);
+			//logger.info(call.cmd+" "+fileName+" "+call.lenIn);
+		} else {
+			logger.error("bad cmd '"+call.cmd+"'");
+			rpc.write( new RpcException("bad cmd '"+call.cmd+"'") );
+			return;
+		}
+		List logInfo = (List)call.args[0];
+		//logger.info("check "+logInfo);
 		RpcResult result = OK;
 		for( Object obj : logInfo ) {
 			Map fileInfo = (Map)obj;
@@ -114,7 +118,7 @@
 			}
 			if( complete ) {
 				LoggingIndexWriter.writeIndex(logs,index);
-				logger.info("write index");
+				//logger.info("write index");
 			}
 		}
 		rpc.write(result);
@@ -124,7 +128,6 @@
 		File zip = File.createTempFile("luan_",".zip");
 		IoUtils.delete(zip);
 		String cmd = "zip -r " + zip + " " + dir.getName();
-logger.info("cmd = "+cmd);
 		synchronized(this) {
 			Process proc = Runtime.getRuntime().exec(cmd,null,dir.getParentFile());
 			IoUtils.waitFor(proc);