aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/services
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-06-27 16:10:41 +0200
committerChristian Schneppe <christian@pix-art.de>2019-06-27 16:10:41 +0200
commit4d5dc70cb358df8732c6aa5f3491fe39c6755452 (patch)
treeea9f5efb7144e3bf0d67e3383525d2ef476bc3f5 /src/main/java/de/pixart/messenger/services
parentb09f0fb91283f3820579465bab6bed46dcb9e4e4 (diff)
catch NPE
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-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) {