diff --git a/app/src/main/kotlin/com/hippo/ehviewer/download/DownloadManager.kt b/app/src/main/kotlin/com/hippo/ehviewer/download/DownloadManager.kt index c8a0168c7..30dbf64a7 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/download/DownloadManager.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/download/DownloadManager.kt @@ -834,6 +834,10 @@ var downloadLocation = with(Settings) { field = value } +fun invalidateDownloadDirCache() { + downloadLocation = downloadLocation.uri.asUniFile() +} + val DownloadInfo.downloadDir get() = dirname?.let { downloadLocation.findFile(it) } val DownloadInfo.archiveFile get() = downloadDir?.run { findFile("$gid.cbz") ?: findFile("$gid.zip") } val GalleryInfo.tempDownloadDir get() = AppConfig.getTempDir("$gid")?.asUniFile() diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/settings/DownloadScreen.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/settings/DownloadScreen.kt index 76f244a72..64ad19385 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/settings/DownloadScreen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/settings/DownloadScreen.kt @@ -37,6 +37,7 @@ import com.hippo.ehviewer.dao.DownloadInfo import com.hippo.ehviewer.download.DownloadManager import com.hippo.ehviewer.download.downloadDir import com.hippo.ehviewer.download.downloadLocation +import com.hippo.ehviewer.download.invalidateDownloadDirCache import com.hippo.ehviewer.spider.COMIC_INFO_FILE import com.hippo.ehviewer.spider.SpiderDen import com.hippo.ehviewer.spider.SpiderQueen.Companion.SPIDER_INFO_FILENAME @@ -215,6 +216,8 @@ fun DownloadScreen(navigator: DestinationsNavigator) = composing(navigator) { }.getOrNull() } runSuspendCatching { + // Rescan download directory for new files added by the user + invalidateDownloadDirCache() val result = downloadLocation.listFiles().parMapNotNull { getRestoreItem(it) }.also { fillGalleryListByApi(it, EhUrl.referer) }