Changeset 32556 in osm for applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
- Timestamp:
- 2016-07-04T14:18:17+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
r32211 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 42 42 super(out); 43 43 } 44 44 45 @Override 45 46 protected void writeStreamHeader() throws IOException { … … 88 89 for (int i = 0; i < files.length; i++) { 89 90 size += files[i].length(); 90 if (files[i].lastModified() < 91 if (files[i].lastModified() < oldestFileDate) { 91 92 oldestFile = i; 92 93 oldestFileDate = files[i].lastModified(); 93 94 } 94 95 } 95 if (size > (long)cacheSize*1024*1024) { 96 if (size > (long) cacheSize*1024*1024) { 96 97 Main.info("Delete oldest file \""+ files[oldestFile].getName() 97 98 + "\" in cache dir to stay under the limit of " + cacheSize + " MB."); … … 120 121 CadastrePlugin.prepareDialog(dialog); 121 122 dialog.setVisible(true); 122 return (Integer)pane.getValue(); 123 return (Integer) pane.getValue(); 123 124 // till here 124 125 } … … 142 143 if (file.exists()) 143 144 file.delete(); 144 while (file.exists()) // wait until file is really gone (otherwise appends to existing one) 145 while (file.exists()) { // wait until file is really gone (otherwise appends to existing one) 145 146 CadastrePlugin.safeSleep(500); 147 } 146 148 } 147 149 … … 158 160 @Override 159 161 public void run() { 160 JOptionPane.showMessageDialog(Main.parent, tr("Error loading file.\nProbably an old version of the cache file."), 162 JOptionPane.showMessageDialog(Main.parent, tr("Error loading file.\nProbably an old version of the cache file."), 161 163 tr("Error"), JOptionPane.ERROR_MESSAGE); 162 164 } … … 193 195 try (ObjectOutputStreamAppend oos = new ObjectOutputStreamAppend( 194 196 new BufferedOutputStream(new FileOutputStream(file, true)))) { 195 for (int i =0; i < size; i++) {197 for (int i = 0; i < size; i++) { 196 198 oos.writeObject(imagesToSave.get(i)); 197 199 } … … 201 203 new BufferedOutputStream(new FileOutputStream(file)))) { 202 204 wmsLayer.write(file, oos); 203 for (int i =0; i < size; i++) {205 for (int i = 0; i < size; i++) { 204 206 oos.writeObject(imagesToSave.get(i)); 205 207 } … … 210 212 } 211 213 imagesLock.lock(); 212 for (int i =0; i < size; i++) {214 for (int i = 0; i < size; i++) { 213 215 imagesToSave.remove(0); 214 216 } 215 217 imagesLock.unlock(); 216 218 } 217 try {wait();} catch (InterruptedException e) { 219 try { 220 wait(); 221 } catch (InterruptedException e) { 218 222 Main.error(e); 219 223 }
Note:
See TracChangeset
for help on using the changeset viewer.