Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6940] Android: Remote image cache does not recognize missing files after activity.finish() and restart

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Fix
Resolution Date2017-07-21T20:59:07.000+0000
Affected Version/sRelease 1.8.0
Fix Version/sn/a
ComponentsAndroid
Labelstbs-1.8.2
ReporterMassimo Morselli
AssigneeEric Merriman
Created2011-11-11T08:21:52.000+0000
Updated2017-07-21T20:59:07.000+0000

Description

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();

Comments

  1. Massimo Morselli 2011-11-12

    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.
  2. Paul Dowsett 2011-12-29

    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
  3. Massimo Morselli 2011-12-29

    Done, sorry ;-)
  4. Paul Dowsett 2011-12-30

    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. :)
  5. Paul Dowsett 2011-12-30

    Massimo Would you verify whether or not this issue is still happening with the latest 1.8.0.1 release? Thank you
  6. Paul Dowsett 2012-01-02

    Massimo Please respond my previous comment. Thanks
  7. Massimo Morselli 2012-01-02

    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
  8. Lee Morris 2017-07-21

    Closing due to inactivity. If this issue still exists, please raise a new ticket

JSON Source