ThumbnailsCacheManager: null out cache when clearing it

Cache is closed when clearing, so it becomes unusable. This way ThumbnailsCacheManager will work as expected

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey 2022-10-18 16:32:50 +02:00
parent 06ddf3ec4d
commit 787804d20b
No known key found for this signature in database
GPG key ID: 2585783189A62105

View file

@ -77,11 +77,10 @@ import java.io.InputStream;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.List; import java.util.List;
import java.util.Locale;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.res.ResourcesCompat; import androidx.core.content.res.ResourcesCompat;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@ -152,7 +151,7 @@ public final class ThumbnailsCacheManager {
mThumbnailCache = new DiskLruImageCache(diskCacheDir, DISK_CACHE_SIZE, mCompressFormat, mThumbnailCache = new DiskLruImageCache(diskCacheDir, DISK_CACHE_SIZE, mCompressFormat,
mCompressQuality); mCompressQuality);
} catch (Exception e) { } catch (Exception e) {
Log_OC.d(TAG, String.format(Locale.US, "Disk cache init failed: %s", e.getMessage())); Log_OC.d(TAG, "Disk cache init failed", e);
mThumbnailCache = null; mThumbnailCache = null;
} }
} }
@ -1378,6 +1377,7 @@ public final class ThumbnailsCacheManager {
@VisibleForTesting @VisibleForTesting
public static void clearCache() { public static void clearCache() {
mThumbnailCache.clearCache(); mThumbnailCache.clearCache();
mThumbnailCache = null;
} }
private static Bitmap doResizedImageInBackground(OCFile file, FileDataStorageManager storageManager) { private static Bitmap doResizedImageInBackground(OCFile file, FileDataStorageManager storageManager) {