Changeset 10417 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-06-18T15:26:31+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
r10406 r10417 45 45 private static long maxObjectTTL = -1; 46 46 private static final String PREFERENCE_PREFIX = "jcs.cache"; 47 p rivatestatic BooleanProperty USE_BLOCK_CACHE = new BooleanProperty(PREFERENCE_PREFIX + ".use_block_cache", true);47 public static BooleanProperty USE_BLOCK_CACHE = new BooleanProperty(PREFERENCE_PREFIX + ".use_block_cache", true); 48 48 49 49 private static final AuxiliaryCacheFactory diskCacheFactory = … … 203 203 BlockDiskCacheAttributes blockAttr = new BlockDiskCacheAttributes(); 204 204 blockAttr.setMaxKeySize(maxDiskObjects); 205 blockAttr.setBlockSizeBytes(4096); // use 4k blocks 205 206 ret = blockAttr; 206 207 } else { … … 216 217 ret.setDiskPath(cachePath); 217 218 } 218 ret.setCacheName(cacheName + (USE_BLOCK_CACHE.get() ? "_BLOCK " : "_INDEX"));219 220 removeStaleFiles(cachePath + File.separator + cacheName, (USE_BLOCK_CACHE.get() ? "_INDEX " : "_BLOCK"));219 ret.setCacheName(cacheName + (USE_BLOCK_CACHE.get() ? "_BLOCK_v2" : "_INDEX_v2")); 220 221 removeStaleFiles(cachePath + File.separator + cacheName, (USE_BLOCK_CACHE.get() ? "_INDEX_v2" : "_BLOCK_v2")); 221 222 return ret; 222 223 } … … 224 225 private static void removeStaleFiles(String basePathPart, String suffix) { 225 226 deleteCacheFiles(basePathPart); // TODO: this can be removed around 2016.09 227 deleteCacheFiles(basePathPart + "_BLOCK"); // TODO: this can be removed around 2016.09 228 deleteCacheFiles(basePathPart + "_INDEX"); // TODO: this can be removed around 2016.09 226 229 deleteCacheFiles(basePathPart + suffix); 227 230 } -
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.