Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Confusing logic in CacheManager function cleanAreaAsync #2012

@mspnr

Description

@mspnr

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:

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions