cgeo icon indicating copy to clipboard operation
cgeo copied to clipboard

c:geo downloading log pictures despite having set "store log pictures" to off

Open moving-bits opened this issue 1 year ago • 3 comments

Report from user on support (ticket 553165):

Since recently c:geo seems to store log pictures offline despite the user having set the "store log pictures" to off. Test case for him was updating 6,000 caches stored offline, and c:geo suddenly taking 50 GB of memory.

(related to #16699)

moving-bits avatar Mar 22 '25 15:03 moving-bits

Added some logging and retrieved the following stack trace on updating a virtual cache:

cgeo.geocaching.network.HtmlImage.fetchDrawableWithMetadata(HtmlImage.java:236), 
cgeo.geocaching.network.HtmlImage.fetchDrawable(HtmlImage.java:232), 
cgeo.geocaching.network.HtmlImage.getDrawable(HtmlImage.java:204), 
cgeo.geocaching.models.Geocache.storeCache(Geocache.java:2156), 
cgeo.geocaching.service.CacheDownloaderService.handleDownload(CacheDownloaderService.java:230), 
cgeo.geocaching.service.CacheDownloaderService.lambda$onHandleIntent$3$cgeo-geocaching-service-CacheDownloaderService(CacheDownloaderService.java:189), 
cgeo.geocaching.service.CacheDownloaderService$$ExternalSyntheticLambda3.subscribe(Unknown Source:4), 
io.reactivex.rxjava3.internal.operators.observable.ObservableCreate.subscribeActual(ObservableCreate.java:41), 
io.reactivex.rxjava3.core.Observable.subscribe(Observable.java:13263), 
io.reactivex.rxjava3.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96), 
io.reactivex.rxjava3.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38), 
io.reactivex.rxjava3.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:25), 
java.util.concurrent.FutureTask.run(FutureTask.java:264), 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145), 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644), java.lang.Thread.run(Thread.java:1012)]

So even though Settings.isStoreLogImages() returns false, analyzing the HTML description already loads all those images and stores them in the app-private folder for geocache data (/storage/emulated/0/Android/data/cgeo.geocaching.developer/files/GeocacheData/<GC-Code>).

How can downloading of log pictures be prevented when Settings.isStoreLogImages() returns false?

Edit: The stack trace above points to this code segment in Geocache.java:

// store spoilers
if (CollectionUtils.isNotEmpty(cache.getSpoilers())) {
    for (final Image oneSpoiler : cache.getSpoilers()) {
        imgGetter.getDrawable(oneSpoiler.getUrl());
    }
}

But (most of) the pictures being downloaded in my short test are definitely NO spoiler pictures, but regular log images.

moving-bits avatar Mar 22 '25 20:03 moving-bits

Ok, the call to addImagesFromGallery(...) is the culprit, as it calls cache.setSpoilers(newImages); for the images found in gallery. Then those images will be handled as if they were spoiler pics (not log pics), thus the check for Settings.isStoreLogImages() will be skipped.

I'll create a PR that calls addImagesFromGallery(...) only if Settings.isStoreLogImages() returns true.

moving-bits avatar Mar 22 '25 20:03 moving-bits

While analyzing #16984 I found that the fix for this issue disabled downloading from gallery images AT ALL now if Settings.isStoreLogImages() is false. Even when opening a cache "live".

How should this be handled. Should gc.com-gallery-images be treated as log images (means: they will appear in the "logs" section of the c:geo image gallery)? Or is there the need of a totally new image gallery category (maybe called "GC Gallery")?

eddiemuc avatar Jun 22 '25 16:06 eddiemuc