Problem
I write this code to clean built-in remote images cache on sd-card, it works, but if I exit app with back button or with activity.finish(), at the next restart all images in my tableview are broken (empty), like the app don't recognize that cache file is missing.
I need to kill app with task killer to have all works fine again.
Test case
// delete cache files
var dir = Titanium.Filesystem.getFile(Titanium.Filesystem.externalStorageDirectory);
var cache_folder = dir.nativePath.toString()+'/remote-image-cache';
var deldir = Titanium.Filesystem.getFile(cache_folder);
deldir.deleteDirectory(true);
// exit app
var activity = Titanium.Android.currentActivity;
activity.finish();
Note that there is no issue with manually deleting (from adb shell) all files in
/mnt/sdcard/(app folder)/remote-image-cache
.
Workaround
Titanium fails if dir remote-image-cache isn't found, so inserting a deldir.createDirectory(); after deldir.deleteDirectory(true); can be used as a workaround:
// delete cache files
var dir = Titanium.Filesystem.getFile(Titanium.Filesystem.externalStorageDirectory);
var cache_folder = dir.nativePath.toString()+'/remote-image-cache';
var deldir = Titanium.Filesystem.getFile(cache_folder);
deldir.deleteDirectory(true);
deldir.createDirectory();
// exit app
var activity = Titanium.Android.currentActivity;
activity.finish();
well, seems that Titanium fails if dir remote-image-cache isn't found, so a deldir.createDirectory(); after deldir.deleteDirectory(true); can be a workaround.
Massimo Thanks for raising this ticket. Please note my changes, to allow it to be escalated. Would you mind completing the environment field, in accordance with the [JIRA Ticket Checklist](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist)? Once this is done, I can move it to the main project. Thank you
Done, sorry ;-)
Thank you, Massimo. No need to apologise. :) Do you really think it is unreasonable for the app to behave this way? Rather than deleting the directory, have you tried deleting just its contents? Anyway, I will move this over to the main project, so we can see what our engineering team says. :)
Massimo Would you verify whether or not this issue is still happening with the latest 1.8.0.1 release? Thank you
Massimo Please respond my previous comment. Thanks
Sorry, but I'm not near my PC for the next 3 days, so I can't do nothing. I will try it as soon as possible at my return
Closing due to inactivity. If this issue still exists, please raise a new ticket