Commit d34622c9 authored by brizental's avatar brizental Committed by Pier Angelo Vendrame
Browse files

TB 42191: [android] Temporary StrictMode relaxation to clear the thumbnail cache.

parent 3b33ea0f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
package mozilla.components.support.utils.cache

import android.content.Context
import android.os.StrictMode
import androidx.annotation.VisibleForTesting
import com.jakewharton.disklrucache.DiskLruCache
import mozilla.components.support.base.log.logger.Logger
@@ -44,10 +45,13 @@ class DiskLruCacheStore(
     */
    fun clear(context: Context) {
        synchronized(cacheLock) {
            val defaultPolicy = StrictMode.allowThreadDiskWrites()
            try {
                getCache(context)?.delete()
            } catch (_: IOException) {
                logger.warn("Cache could not be cleared. Perhaps there are none?")
            } finally {
                StrictMode.setThreadPolicy(defaultPolicy)
            }

            cache = null