aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index b9945de0a..09739530d 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -767,23 +767,30 @@ public class XmppConnectionService extends Service {
private void deleteWebpreviewCache() {
long start = SystemClock.elapsedRealtime();
- final String path = getApplicationContext().getCacheDir() + "/" + RICH_LINK_METADATA;
- final Calendar time = Calendar.getInstance();
- time.add(Calendar.DAY_OF_YEAR, -7);
- final File directory = new File(path);
- final File[] files = directory.listFiles();
- if (files == null) {
- return;
- }
- int count = 0;
- for (File file : files) {
- Date lastModified = new Date(file.lastModified());
- if (lastModified.before(time.getTime())) {
- file.delete();
- count++;
+ try {
+ final String path = getApplicationContext().getCacheDir() + "/" + RICH_LINK_METADATA;
+ final Calendar time = Calendar.getInstance();
+ time.add(Calendar.DAY_OF_YEAR, -7);
+ final File directory = new File(path);
+ if (!directory.exists()) {
+ return;
}
+ final File[] files = directory.listFiles();
+ if (files == null) {
+ return;
+ }
+ int count = 0;
+ for (File file : files) {
+ Date lastModified = new Date(file.lastModified());
+ if (lastModified.before(time.getTime())) {
+ file.delete();
+ count++;
+ }
+ }
+ Log.d(Config.LOGTAG, "Deleted " + count + " expired webpreview cache files in " + (SystemClock.elapsedRealtime() - start) + "ms");
+ } catch (Exception e) {
+ Log.d(Config.LOGTAG, "Deleted no expired webpreview cache files because of " + e + " in " + (SystemClock.elapsedRealtime() - start) + "ms");
}
- Log.d(Config.LOGTAG, "Deleted " + count + " expired webpreview cache files in " + (SystemClock.elapsedRealtime() - start) + "ms");
}
private boolean processAccountState(Account account, boolean interactive, boolean isUiAction, boolean isAccountPushed, HashSet<Account> pingCandidates) {