Skip to content

Commit ed83c73

Browse files
committed
Recover from corrupt image cache journal via image loader
1 parent e639005 commit ed83c73

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android {
1212
applicationId "com.tomclaw.appsend"
1313
minSdkVersion 23
1414
targetSdkVersion 36
15-
versionCode project.hasProperty("versionCode") ? Integer.parseInt(project.versionCode) : 1090
15+
versionCode project.hasProperty("versionCode") ? Integer.parseInt(project.versionCode) : 1091
1616
versionName = "21.0"
1717
}
1818

@@ -86,7 +86,7 @@ dependencies {
8686
// Standard Libraries
8787
implementation 'com.github.solkin:bananalytics-android:v1.0.0'
8888
implementation 'androidx.preference:preference-ktx:1.2.1'
89-
implementation 'com.github.solkin:simple-image-loader:v1.2.0'
89+
implementation 'com.github.solkin:simple-image-loader:v1.3.0'
9090
implementation 'com.github.solkin:disk-lru-cache:v1.8'
9191

9292
// AndroidX Core & UI

app/src/main/java/com/tomclaw/appsend/Appteka.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ import com.tomclaw.appsend.util.AppIconLoader
1212
import com.tomclaw.appsend.util.EdgeToEdgeActivityCallback
1313
import com.tomclaw.appsend.util.SvgDecoder
1414
import com.tomclaw.appsend.util.ThemeManager
15-
import com.tomclaw.cache.DiskLruCache
1615
import com.tomclaw.imageloader.SimpleImageLoader.initImageLoader
17-
import com.tomclaw.imageloader.core.DiskCacheImpl
16+
import com.tomclaw.imageloader.core.DiskCache
1817
import com.tomclaw.imageloader.core.FileProviderImpl
1918
import com.tomclaw.imageloader.core.MainExecutorImpl
2019
import com.tomclaw.imageloader.core.MemoryCacheImpl
@@ -73,7 +72,9 @@ class Appteka : Application() {
7372
decoders = listOf(SvgDecoder(), BitmapDecoder()),
7473
fileProvider = FileProviderImpl(
7574
cacheDir,
76-
DiskCacheImpl(DiskLruCache.create(cacheDir, DISK_CACHE_SIZE)),
75+
// DiskCache.create recovers from a corrupt journal on its own instead
76+
// of throwing, so a bad cache no longer crashes every icon bind.
77+
DiskCache.create(cacheDir, DISK_CACHE_SIZE),
7778
UrlLoader(),
7879
FileLoader(assets),
7980
ContentLoader(contentResolver),
@@ -84,7 +85,8 @@ class Appteka : Application() {
8485
mainExecutor = MainExecutorImpl(),
8586
backgroundExecutor = Executors.newFixedThreadPool(IMAGE_LOADER_THREADS)
8687
)
87-
} catch (ignored: Throwable) {
88+
} catch (ex: Throwable) {
89+
Log.e(TAG, "Failed to init image loader", ex)
8890
}
8991
}
9092

0 commit comments

Comments
 (0)