Changeset 31053 in osm for applications
- Timestamp:
- 2015-03-06T02:36:22+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java
r31052 r31053 132 132 File tileCacheDir; 133 133 File tileFile = null; 134 File tagsFile = null; 134 135 Long fileMtime = null; 135 136 Long now = null; // current time in milliseconds (keep consistent value for the whole run) … … 155 156 now = System.currentTimeMillis(); 156 157 tileCacheDir = getSourceCacheDir(tile.getSource()); 158 tileFile = getTileFile(); 159 tagsFile = getTagsFile(); 157 160 158 161 loadTagsFromFile(); 159 162 160 if (is TileFileValid() && (isNoTileAtZoom() || loadTileFromFile())) {163 if (isCacheValid() && (isNoTileAtZoom() || loadTileFromFile())) { 161 164 log.log(Level.FINE, "TMS - found in tile cache: {0}", tile); 162 165 tile.setLoaded(true); … … 287 290 } 288 291 289 protected boolean is TileFileValid() {292 protected boolean isCacheValid() { 290 293 Long expires = null; 291 294 try { … … 305 308 // so handle properly the case, when only tags file exists 306 309 fileMtime = tileFile.lastModified(); 307 if (now - fileMtime > DEFAULT_EXPIRES_TIME) { 308 log.log(Level.FINE, "TMS - Tile has expired, maximum file age reached {0}", tile); 309 return false; 310 } 310 } else if (tagsFile.exists()) { 311 fileMtime = tagsFile.lastModified(); 312 } else 313 return false; 314 315 if (now - fileMtime > DEFAULT_EXPIRES_TIME) { 316 log.log(Level.FINE, "TMS - Tile has expired, maximum file age reached {0}", tile); 317 return false; 311 318 } 312 319 } … … 337 344 log.log(Level.WARNING, "TMS - Error while loading image from tile cache: {0}; {1}", new Object[]{e.getMessage(), tile}); 338 345 tileFile.delete(); 339 File tileMetaData = getTagsFile();340 if (tileMetaData.exists())341 tileMetaData.delete();346 if (tagsFile.exists()) { 347 tagsFile.delete(); 348 } 342 349 tileFile = null; 343 350 fileMtime = null; … … 454 461 455 462 protected boolean loadTagsFromFile() { 456 tileFile = getTileFile();457 463 File tagsFile = getTagsFile(); 458 464 try (BufferedReader f = new BufferedReader(new InputStreamReader(new FileInputStream(tagsFile), TAGS_CHARSET))) {
Note:
See TracChangeset
for help on using the changeset viewer.