-
Notifications
You must be signed in to change notification settings - Fork 1k
Confusing logic in CacheManager function cleanAreaAsync #2012
Description
I am trying to clean up cache and found very strange behavior in CacheManager function cleanAreaAsync. It looks like cache is cleaned all right, but it always displaying a toast "Cleaning failed. XX tiles deleted" at the end.
I would not expect such an message in case of successful cache cleaning.
Issue Type
[X] Bug
Reproducing
This is how I call the function from my app (remove tiles, displayed on the screen in current zoom):
MapView map;
CacheManager mgr = new CacheManager(map);
mgr.cleanAreaAsync(activity,
map.getBoundingBox(),
(int) map.getZoomLevelDouble(),
(int) map.getZoomLevelDouble()
);It goes back an forth and ends up here:
osmdroid/osmdroid-android/src/main/java/org/osmdroid/tileprovider/cachemanager/CacheManager.java
Lines 796 to 797 in e85b32e
| if (mAction.tileAction(tile)) { | |
| errors++; |
In my case this tileAction returns true in case of success. In this case error counter is increased, returned at the end of the function and later on triggers onTaskFailed.
Maybe for deletion of tiles this logic should be opposite?
Also here what is happening inside tileAction on cleaning cache:
osmdroid/osmdroid-android/src/main/java/org/osmdroid/tileprovider/cachemanager/CacheManager.java
Line 178 in e85b32e
| return mTileWriter.exists(mTileSource, pMapTileIndex) && mTileWriter.remove(mTileSource, pMapTileIndex); |
Side note: deletion is considered successful only if it exists and was deleted all right. Maybe it is pretty harsh. I would better consider error if there was a problem on deletion. Non-existing tile is means, cache is already clean. But this is optional.
Version of osmdroid the issue relates to:
6.1.18