diff --git a/CHANGELOG.md b/CHANGELOG.md index e4fcccc6a..ace2e225d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co ### Added - Support resumable image downloads if supported by source ([@xMohnad](https://github.com/xMohnad)) ([#3167](https://github.com/mihonapp/mihon/pull/3167)) - Display authors and description in Shikimori search results ([@MajorTanya](https://github.com/MajorTanya)) ([#3499](https://github.com/mihonapp/mihon/pull/3499)) +- Invalidate download cache after backup restore ([@leodyversemilla07](https://github.com/leodyversemilla07)) ([#3096](https://github.com/mihonapp/mihon/pull/3096)) ### Fixed - Fix Shikimori tracking not working ([@MajorTanya](https://github.com/MajorTanya)) ([#3497](https://github.com/mihonapp/mihon/pull/3497)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/BackupRestorer.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/BackupRestorer.kt index fe9c55b54..b38086513 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/BackupRestorer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/restore/BackupRestorer.kt @@ -13,12 +13,15 @@ import eu.kanade.tachiyomi.data.backup.restore.restorers.CategoriesRestorer import eu.kanade.tachiyomi.data.backup.restore.restorers.ExtensionStoreRestorer import eu.kanade.tachiyomi.data.backup.restore.restorers.MangaRestorer import eu.kanade.tachiyomi.data.backup.restore.restorers.PreferenceRestorer +import eu.kanade.tachiyomi.data.download.DownloadCache import eu.kanade.tachiyomi.util.system.createFileInCacheDir import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.ensureActive import kotlinx.coroutines.launch +import logcat.LogPriority import tachiyomi.core.common.i18n.stringResource +import tachiyomi.core.common.util.system.logcat import tachiyomi.data.Database import tachiyomi.i18n.MR import uy.kohesive.injekt.Injekt @@ -59,6 +62,15 @@ class BackupRestorer( restoreFromFile(uri, options) + // Invalidate download cache to ensure UI reflects any restored downloads + if (options.libraryEntries) { + try { + Injekt.get().invalidateCache() + } catch (e: Exception) { + logcat(LogPriority.ERROR, e) { "Failed to invalidate download cache after restore" } + } + } + val time = System.currentTimeMillis() - startTime val logFile = writeErrorLog()