Changeset 8186 in josm for trunk/src/org
- Timestamp:
- 2015-04-10T14:06:46+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
r8172 r8186 3 3 4 4 import java.io.File; 5 import java.io.FileOutputStream; 5 6 import java.io.IOException; 7 import java.nio.channels.FileLock; 6 8 import java.text.MessageFormat; 7 9 import java.util.Properties; … … 40 42 private final static String PREFERENCE_PREFIX = "jcs.cache"; 41 43 private final static IndexedDiskCacheFactory diskCacheFactory = new IndexedDiskCacheFactory(); 44 private static FileLock cacheDirLock = null; 42 45 43 46 /** … … 46 49 public static final IntegerProperty DEFAULT_MAX_OBJECTS_IN_MEMORY = new IntegerProperty(PREFERENCE_PREFIX + ".max_objects_in_memory", 1000); 47 50 51 @SuppressWarnings("resource") 48 52 private static void initialize() throws IOException { 49 53 File cacheDir = new File(Main.pref.getCacheDirectory(), "jcs"); … … 51 55 if ((!cacheDir.exists() && !cacheDir.mkdirs())) 52 56 throw new IOException("Cannot access cache directory"); 57 58 File cacheDirLockPath = new File(cacheDir, ".lock"); 59 if (!cacheDirLockPath.exists()) 60 cacheDirLockPath.createNewFile(); 61 cacheDirLock = new FileOutputStream(cacheDirLockPath).getChannel().tryLock(); 62 63 if (cacheDirLock == null) 64 log.log(Level.WARNING, "Cannot lock cache directory. Will not use disk cache"); 53 65 54 66 // raising logging level gives ~500x performance gain … … 139 151 CompositeCache<K, V> cc = cacheManager.getCache(cacheName, getCacheAttributes(maxMemoryObjects)); 140 152 141 if (cachePath != null) { 153 if (cachePath != null && cacheDirLock != null) { 142 154 IndexedDiskCacheAttributes diskAttributes = getDiskCacheAttributes(maxDiskObjects, cachePath); 143 155 diskAttributes.setCacheName(cacheName); -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java
r8174 r8186 62 62 63 63 @Override 64 public void clearCache() { 64 public void clearCache(TileSource source) { 65 65 this.cache.clear(); 66 66 } -
trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
r8168 r8186 194 194 tileCache.clear(); 195 195 if (tileLoader instanceof CachedTileLoader) { 196 ((CachedTileLoader)tileLoader).clearCache(); 196 ((CachedTileLoader)tileLoader).clearCache(tileSource); 197 197 } 198 198 }
Note:
See TracChangeset
for help on using the changeset viewer.