Mercurial Hosting > luan
comparison src/goodjava/lucene/backup/Backup.java @ 1677:ea7075b7afe1
switch to index.json
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 31 May 2022 14:36:16 -0600 |
parents | af18eacf187c |
children | aff2309ae510 |
comparison
equal
deleted
inserted
replaced
1676:daa4214fa91a | 1677:ea7075b7afe1 |
---|---|
23 | 23 |
24 final class Backup { | 24 final class Backup { |
25 private static final Logger logger = LoggerFactory.getLogger(Backup.class); | 25 private static final Logger logger = LoggerFactory.getLogger(Backup.class); |
26 | 26 |
27 private final File dir; | 27 private final File dir; |
28 private final File index; | 28 private final File indexFile; |
29 | 29 |
30 Backup(File dir) { | 30 Backup(File dir) { |
31 this.dir = dir; | 31 this.dir = dir; |
32 this.index = new File(dir,"index"); | 32 this.indexFile = new File(dir,"index.json"); |
33 dir.setLastModified(System.currentTimeMillis()); | 33 dir.setLastModified(System.currentTimeMillis()); |
34 } | 34 } |
35 | 35 |
36 void handle(RpcServer rpc,RpcCall call) { | 36 void handle(RpcServer rpc,RpcCall call) { |
37 try { | 37 try { |
96 } | 96 } |
97 Object checksumObj = fileInfo.get("checksum"); | 97 Object checksumObj = fileInfo.get("checksum"); |
98 if( checksumObj != null ) { | 98 if( checksumObj != null ) { |
99 long checksum = (Long)checksumObj; | 99 long checksum = (Long)checksumObj; |
100 if( log.checksum() != checksum ) { | 100 if( log.checksum() != checksum ) { |
101 index.delete(); | 101 indexFile.delete(); |
102 result = new RpcResult(new Object[]{"bad_checksum",name}); | 102 result = new RpcResult(new Object[]{"bad_checksum",name}); |
103 break; | 103 break; |
104 } | 104 } |
105 } | 105 } |
106 } | 106 } |
116 break; | 116 break; |
117 } | 117 } |
118 logs[i] = new LogFile(f); | 118 logs[i] = new LogFile(f); |
119 } | 119 } |
120 if( complete ) { | 120 if( complete ) { |
121 LoggingIndexWriter.writeIndex(logs,index); | 121 LoggingIndexWriter.writeIndex(logs,indexFile); |
122 //logger.info("write index"); | 122 //logger.info("write index"); |
123 } | 123 } |
124 } | 124 } |
125 rpc.write(result); | 125 rpc.write(result); |
126 } | 126 } |