Steps to reproduce
1) Enter airplane mode
2) Open Matomo Example App
3) Track Screen View
4) Press the home button
At this point the piwik_cache directory is created and an event is stored there
5) App Info for Matomo Example App and Clear Cache
6) Reenter the Matomo Example app
7) Track Screen View
8) While watching the logcat press the home button
E java.io.FileNotFoundException: /data/user/0/org.matomo.demo/cache/piwik_cache/example.com/events_1626142384160: open failed: ENOENT (No such file or directory)
E at libcore.io.IoBridge.open(IoBridge.java:497)
E at java.io.FileOutputStream.<init>(FileOutputStream.java:236)
E at java.io.FileOutputStream.<init>(FileOutputStream.java:186)
E at java.io.FileWriter.<init>(FileWriter.java:90)
E at org.matomo.sdk.dispatcher.EventDiskCache.writeEventFile(EventDiskCache.java:201)
E at org.matomo.sdk.dispatcher.EventDiskCache.cache(EventDiskCache.java:116)
E at org.matomo.sdk.dispatcher.EventCache.updateState(EventCache.java:51)
E at org.matomo.sdk.dispatcher.DefaultDispatcher$1.run(DefaultDispatcher.java:201)
E at java.lang.Thread.run(Thread.java:920)
E Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
E at libcore.io.Linux.open(Native Method)
E at libcore.io.ForwardingOs.open(ForwardingOs.java:239)
E at libcore.io.BlockGuardOs.open(BlockGuardOs.java:273)
E at libcore.io.ForwardingOs.open(ForwardingOs.java:239)
E at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7682)
E at libcore.io.IoBridge.open(IoBridge.java:483)
E ... 8 more
The directory is created when EventDiskCache is instantiated but since clearing an app cache can be done without restarting the app it's not enough. I propose calling mCacheDir.mkdirs() in writeEventFile
Steps to reproduce 1) Enter airplane mode 2) Open Matomo Example App 3) Track Screen View 4) Press the home button At this point the
piwik_cache
directory is created and an event is stored there 5) App Info for Matomo Example App and Clear Cache 6) Reenter the Matomo Example app 7) Track Screen View 8) While watching the logcat press the home buttonThe directory is created when
EventDiskCache
is instantiated but since clearing an app cache can be done without restarting the app it's not enough. I propose callingmCacheDir.mkdirs()
inwriteEventFile