cgeo / cgeo

c:geo - The powerful Android geocaching app.
www.cgeo.org
Apache License 2.0
1.39k stars 566 forks source link

Default base folder "cgeo" automatically recreated #11416

Closed fm-sys closed 2 years ago

fm-sys commented 3 years ago

Describe your problem!

I have just set my cgeo base folder to emulated/0/Locus as many files are needed for both apps.

However, although I have deleted the old "cgeo" base folder it gets always recreated when I start cgeo, which pollutes the storage without any value...

How to reproduce?

Actual result after these steps?

No response

Expected result after these steps?

No response

Reproducible

Unclear

c:geo Version

Current nightly

System information

## System information

c:geo version: 2021.08.04-NB-7870353

Device:
-------
- Device type: SNE-LX1 (SNE-LX1, HUAWEI)
- Available processors: 8
- Android version: 10
- Android build: SNE-LX1 10.0.0.245(C432E10R1P1)
- Screen resolution: 1080x2250px (360x750dp)
- Sailfish OS detected: false
- Google Play services: enabled - 21.24.18 (120408-383468479)
- HW acceleration: enabled (default state)

Sensor and location:
-------
- Low power mode: inactive
- Compass capabilities: yes
- Rotation vector sensor: present
- Orientation sensor: present
- Magnetometer & Accelerometer sensor: present
- Direction sensor used: rotation vector

Program settings:
-------
- Filters: 
    LIVE: Cache-Typ:Tradi ([:inconclusive=false:advanced=false]AND(type:TRADITIONAL;difficulty_terrain:difficulty=-:difficulty=-:terrain=-:terrain=-;status))
    OFFLINE: Offline Log ([Offline Log:inconclusive=false:advanced=false]AND(status:has_offline_log_yes))
- Hide waypoints: parking 
- Set language: de_DE (system default)
- System date format: dd.MM.yy
- Debug mode active: no
- Live map mode: true
- OSM multi-threading: false / threads: 1
- Last backup: 5. Aug., 16:34
- Routing mode: Walk
- Settings: v8, Count:190
- Map: Kombiniert (Offline)
  - Id: cgeo.geocaching.maps.mapsforge.MapsforgeMapProvider$OfflineMultiMapSource
  - Atts: austria.map: / Map data (c) OpenStreetMap contributors /  / Dubai.map: / mapsforge-map-writer-0.9.0 /  / germany.map: / Map data (c) OpenStreetMap contributors /  / nord-est.map: / Map data (c) OpenStreetMap contributors /  / world.map: / mapsforge-map-writer-dev-SNAPSHOT
  - Theme: none

Services:
-------
- Geocaching sites enabled:
   geocaching.com: Logged in (Anmeldung OK) / PREMIUM
   Geocaching.com Adventure Lab
- Geocaching.com date format: dd.MM.yyyy
- Routing: external / BRouter installed: true
- Installed c:geo plugins:  none

Permissions & paths:
-------
- Fine location permission: granted
- Write external storage permission: granted
- System internal c:geo dir: /data/user/0/cgeo.geocaching (2,2 GB free) v2 internal isDir(6 entries)
- Legacy User storage c:geo dir: /storage/emulated/0/cgeo (2,2 GB free) v2 external non-removable isDir(0 entries)
- Geocache data: /storage/emulated/0/Android/data/cgeo.geocaching/files/GeocacheData (2,2 GB free) v2 external non-removable isDir(231 entries)
- Internal theme sync (is turned off): /data/user/0/cgeo.geocaching/MapThemeData (2,2 GB free) v2 internal isDir(0 entries)
- Public Folders: #11
  - BASE: /Locus (User-Defined)[/Locus[DOCUMENT#0:p-content://com.android.externalstorage.documents/tree/primary%3ALocus::]] (Uri: content://com.android.externalstorage.documents/tree/primary%3ALocus/document/primary%3ALocus, Av:true, files:>=14, dirs:>=29, totalFileSize:>=117,0 MB, free space: 2,2 GB, files on device: 12925952)
  - OFFLINE_MAPS: /Locus/maps (Default)[/Locus/maps[PERSISTABLE_FOLDER(BASE)#1:p-content://com.android.externalstorage.documents/tree/primary%3ALocus::/maps]] (Uri: content://com.android.externalstorage.documents/tree/primary%3ALocus/document/primary%3ALocus%2Fmaps, Av:true, files:14, dirs:1, totalFileSize:3,2 GB, free space: 2,2 GB, files on device: 12925952)
  - OFFLINE_MAP_THEMES: /Locus/maps/_themes (Default)[/Locus/maps/_themes[PERSISTABLE_FOLDER(OFFLINE_MAPS)#1:p-content://com.android.externalstorage.documents/tree/primary%3ALocus::/maps/_themes]] (Uri: content://com.android.externalstorage.documents/tree/primary%3ALocus/document/primary%3ALocus%2Fmaps%2F_themes, Av:true, files:7, dirs:0, totalFileSize:4,5 MB, free space: 2,2 GB, files on device: 12925952)
  - LOGFILES: /Locus/logfiles (Default)[/Locus/logfiles[PERSISTABLE_FOLDER(BASE)#1:p-content://com.android.externalstorage.documents/tree/primary%3ALocus::/logfiles]] (Uri: content://com.android.externalstorage.documents/tree/primary%3ALocus/document/primary%3ALocus%2Flogfiles, Av:true, files:9, dirs:0, totalFileSize:119,1 KB, free space: 2,2 GB, files on device: 12925952)
  - GPX: /Locus/gpx (Default)[/Locus/gpx[PERSISTABLE_FOLDER(BASE)#1:p-content://com.android.externalstorage.documents/tree/primary%3ALocus::/gpx]] (Uri: content://com.android.externalstorage.documents/tree/primary%3ALocus/document/primary%3ALocus%2Fgpx, Av:true, files:27, dirs:1, totalFileSize:17,9 MB, free space: 2,2 GB, files on device: 12925952)
  - BACKUP: /Locus/backup (Default)[/Locus/backup[PERSISTABLE_FOLDER(BASE)#1:p-content://com.android.externalstorage.documents/tree/primary%3ALocus::/backup]] (Uri: content://com.android.externalstorage.documents/tree/primary%3ALocus/document/primary%3ALocus%2Fbackup, Av:true, files:>=13, dirs:>=14, totalFileSize:>=146,2 MB, free space: 2,2 GB, files on device: 12925952)
  - FIELD_NOTES: /Locus/field-notes (Default)[/Locus/field-notes[PERSISTABLE_FOLDER(BASE)#1:p-content://com.android.externalstorage.documents/tree/primary%3ALocus::/field-notes]] (Uri: content://com.android.externalstorage.documents/tree/primary%3ALocus/document/primary%3ALocus%2Ffield-notes, Av:true, files:1, dirs:0, totalFileSize:0 B, free space: 2,2 GB, files on device: 12925952)
  - SPOILER_IMAGES: /Locus/GeocachePhotos (Default)[/Locus/GeocachePhotos[PERSISTABLE_FOLDER(BASE)#1:p-content://com.android.externalstorage.documents/tree/primary%3ALocus::/GeocachePhotos]] (Uri: content://com.android.externalstorage.documents/tree/primary%3ALocus/document/primary%3ALocus%2FGeocachePhotos, Av:true, files:0, dirs:0, totalFileSize:0 B, free space: 2,2 GB, files on device: 12925952)
  - ROUTING_BASE: /Locus/routing (Default)[/Locus/routing[PERSISTABLE_FOLDER(BASE)#1:p-content://com.android.externalstorage.documents/tree/primary%3ALocus::/routing]] (Uri: content://com.android.externalstorage.documents/tree/primary%3ALocus/document/primary%3ALocus%2Frouting, Av:true, files:7, dirs:1, totalFileSize:81,2 KB, free space: 2,2 GB, files on device: 12925952)
  - ROUTING_TILES: /Locus/routing/segments4 (Default)[/Locus/routing/segments4[PERSISTABLE_FOLDER(ROUTING_BASE)#1:p-content://com.android.externalstorage.documents/tree/primary%3ALocus::/routing/segments4]] (Uri: content://com.android.externalstorage.documents/tree/primary%3ALocus/document/primary%3ALocus%2Frouting%2Fsegments4, Av:true, files:0, dirs:0, totalFileSize:0 B, free space: 2,2 GB, files on device: 12925952)
  - TEST_FOLDER: [Legacy]/data/user/0/cgeo.geocaching/files/unittest (Default)[/data/user/0/cgeo.geocaching/files/unittest[FILE#1:p-file:///data/user/0/cgeo.geocaching/files::/unittest]] (Uri: file:///data/user/0/cgeo.geocaching/files/unittest, Av:true, files:0, dirs:0, totalFileSize:0 B, free space: 2,2 GB, files on device: -1)
- Map render theme path: 
- PersistedDocumentUris: #1
- TRACK: null
- Persisted Uri Permissions: #1
  - content://com.android.externalstorage.documents/tree/primary%3ALocus (5. Aug., 16:33):RW
- Database: /data/user/0/cgeo.geocaching/databases/data (v96, Size:35,7 MB) on system internal storage

--- End of system information ---

Additional Information

Screenshot_20210805_174918_com huawei hidisk

eddiemuc commented 3 years ago

I have an idea what the source of this bug might be: the upfront checks whether the default folders are accessible might be a little too "successful" here...

eddiemuc commented 3 years ago

Jupp, guessed right. This is happening because at startup c:geo checks for all folders whether their default is accessible (and when doing that it creates said default folders).

This is not easy to solve, the default folder check must be moved to the time it is first needed. Something for a long winter night with no other c:geo issues lying around...

Lineflyer commented 3 years ago

What happens if we (one day) plainly remove the legacy file access permissions?

eddiemuc commented 3 years ago

What happens if we (one day) plainly remove the legacy file access permissions?

Then the problem will be gone.

I also have to add that I am almost completely sure that the problem will only happen on Android <= 10, not in Android 11 any more. Because the default file creation process should simply not work there (which is then handled correctly by c:geo, don't worry). It is actually the "trying whether we could reach the folder" which currently results in the unwanted creation of the folder. (Note: have to admit that this is all guess-work by now after looking into code, haven't tested this for real yet)

fm-sys commented 2 years ago

Might be solved implicitly by #11791. Should be retested as soon as the PR is merged...

fm-sys commented 2 years ago

Yes, is indeed fixed. Thanks @eddiemuc for improving the startup performance and (implicitly) fixing this issue 👍