From 11127c0d9789858a3b80b11f0b4eb018077bd068 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Wed, 19 Sep 2018 16:41:51 -0700 Subject: [PATCH] Clear external cache upon upgrade. --- .../securesms/DatabaseUpgradeActivity.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java b/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java index b682d16a6c..59525d9f9a 100644 --- a/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java +++ b/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java @@ -43,6 +43,7 @@ import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob; import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob; import org.thoughtcrime.securesms.jobs.PushDecryptJob; import org.thoughtcrime.securesms.jobs.RefreshAttributesJob; +import org.thoughtcrime.securesms.mms.GlideApp; import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.service.KeyCachingService; import org.thoughtcrime.securesms.util.FileUtils; @@ -83,6 +84,7 @@ public class DatabaseUpgradeActivity extends BaseActivity { public static final int REMOVE_CACHE = 354; public static final int FULL_TEXT_SEARCH = 358; public static final int BAD_IMPORT_CLEANUP = 373; + public static final int IMAGE_CACHE_CLEANUP = 406; private static final SortedSet UPGRADE_VERSIONS = new TreeSet() {{ add(NO_MORE_KEY_EXCHANGE_PREFIX_VERSION); @@ -105,6 +107,7 @@ public class DatabaseUpgradeActivity extends BaseActivity { add(REMOVE_CACHE); add(FULL_TEXT_SEARCH); add(BAD_IMPORT_CLEANUP); + add(IMAGE_CACHE_CLEANUP); }}; private MasterSecret masterSecret; @@ -306,6 +309,15 @@ public class DatabaseUpgradeActivity extends BaseActivity { } } + if (params[0] < IMAGE_CACHE_CLEANUP) { + try { + FileUtils.deleteDirectoryContents(context.getExternalCacheDir()); + GlideApp.get(context).clearDiskCache(); + } catch (IOException e) { + Log.w(TAG, e); + } + } + return null; }