comparison src/goodjava/lucene/backup/Backup.java @ 1508:86c5e7000ecf

lucene.backup checksum
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 16 May 2020 17:56:02 -0600
parents e66e3d50b289
children 0ba144491a42
comparison
equal deleted inserted replaced
1507:c8f4867fd083 1508:86c5e7000ecf
43 if( call.cmd.equals("check") ) { 43 if( call.cmd.equals("check") ) {
44 // nothing 44 // nothing
45 } else if( call.cmd.equals("add") || call.cmd.equals("append") ) { 45 } else if( call.cmd.equals("add") || call.cmd.equals("append") ) {
46 fileName = (String)call.args[2]; 46 fileName = (String)call.args[2];
47 File f = new File(dir,fileName); 47 File f = new File(dir,fileName);
48 if( call.cmd.equals("add") )
49 IoUtils.delete(f);
48 LogFile log = new LogFile(f); 50 LogFile log = new LogFile(f);
49 LogOutputStream out = log.output(); 51 LogOutputStream out = log.output();
50 IoUtils.copyAll(call.in,out); 52 IoUtils.copyAll(call.in,out);
51 out.commit(); 53 out.commit();
52 out.close(); 54 out.close();
76 if( logEnd < end ) { 78 if( logEnd < end ) {
77 if( name.equals(fileName) ) logger.error("incomplete"); 79 if( name.equals(fileName) ) logger.error("incomplete");
78 result = new RpcResult("incomplete",name,logEnd); 80 result = new RpcResult("incomplete",name,logEnd);
79 break; 81 break;
80 } 82 }
83 Object checksumObj = fileInfo.get("checksum");
84 if( checksumObj != null ) {
85 long checksum = (Long)checksumObj;
86 if( log.checksum() != checksum ) {
87 index.delete();
88 result = new RpcResult("bad_checksum",name);
89 break;
90 }
91 }
81 } 92 }
82 if( call.cmd.equals("add") ) { 93 if( call.cmd.equals("add") ) {
83 boolean complete = true; 94 boolean complete = true;
84 List<LogFile> logs = new ArrayList<LogFile>(); 95 List<LogFile> logs = new ArrayList<LogFile>();
85 for( Object obj : logInfo ) { 96 for( Object obj : logInfo ) {