Changeset 10417 in josm for trunk/src/org/openstreetmap/josm/gui/preferences/imagery
- Timestamp:
- 2016-06-18T15:26:31+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CommonSettingsPanel.java
r8861 r10417 8 8 import java.awt.event.ActionEvent; 9 9 import java.awt.event.ActionListener; 10 import java.io.File; 11 import java.io.FilenameFilter; 10 12 11 13 import javax.swing.JButton; … … 18 20 import javax.swing.SpinnerNumberModel; 19 21 22 import org.openstreetmap.josm.data.cache.JCSCacheManager; 20 23 import org.openstreetmap.josm.data.imagery.CachedTileLoaderFactory; 21 24 import org.openstreetmap.josm.gui.layer.AbstractCachedTileSourceLayer; … … 26 29 import org.openstreetmap.josm.tools.ColorHelper; 27 30 import org.openstreetmap.josm.tools.GBC; 31 import org.openstreetmap.josm.tools.Utils; 28 32 29 33 /** … … 129 133 boolean restartRequired = false; 130 134 if (!AbstractCachedTileSourceLayer.MAX_DISK_CACHE_SIZE.get().equals(this.maxElementsOnDisk.getValue())) { 135 if (((Integer)this.maxElementsOnDisk.getValue()) < AbstractCachedTileSourceLayer.MAX_DISK_CACHE_SIZE.get() && 136 JCSCacheManager.USE_BLOCK_CACHE.get()) { 137 // reducing size of the cache, this requires deletion of the files 138 removeCacheFiles(CachedTileLoaderFactory.PROP_TILECACHE_DIR.get()); 139 } 131 140 AbstractCachedTileSourceLayer.MAX_DISK_CACHE_SIZE.put((Integer) this.maxElementsOnDisk.getValue()); 132 141 restartRequired = true; … … 136 145 if (!CachedTileLoaderFactory.PROP_TILECACHE_DIR.get().equals(this.tilecacheDir.getText())) { 137 146 restartRequired = true; 147 removeCacheFiles(CachedTileLoaderFactory.PROP_TILECACHE_DIR.get()); // clear old cache directory 138 148 CachedTileLoaderFactory.PROP_TILECACHE_DIR.put(this.tilecacheDir.getText()); 139 149 } … … 146 156 return restartRequired; 147 157 } 158 159 private void removeCacheFiles(String path) { 160 File directory = new File(path); 161 File[] cacheFiles = directory.listFiles(new FilenameFilter() { 162 @Override 163 public boolean accept(File dir, String name) { 164 return name.endsWith(".data") || name.endsWith(".key"); 165 } 166 167 }); 168 JCSCacheManager.shutdown(); // shutdown Cache - so files can by safely deleted 169 for (File cacheFile: cacheFiles) { 170 Utils.deleteFile(cacheFile); 171 } 172 } 148 173 }
Note:
See TracChangeset
for help on using the changeset viewer.