From 0fd8054963cb8bf17c5a72b3f53b720eb1830056 Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Sun, 22 Sep 2024 13:56:44 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/model/CacheBook.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/CacheBook.kt b/app/src/main/java/io/legado/app/model/CacheBook.kt index 32d33970f9cc..9b36b760c81f 100644 --- a/app/src/main/java/io/legado/app/model/CacheBook.kt +++ b/app/src/main/java/io/legado/app/model/CacheBook.kt @@ -267,7 +267,7 @@ object CacheBook { waitDownloadSet.remove(chapterIndex) onDownloadSet.add(chapterIndex) if (BookHelp.hasContent(book, chapter)) { - Coroutine.async(executeContext = context) { + Coroutine.async(scope, context, executeContext = context) { BookHelp.getContent(book, chapter)?.let { BookHelp.saveImages(bookSource, book, chapter, it, 1) } From 6df00e9f499d4fb2ad20ac0d725f13853e410f73 Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Tue, 24 Sep 2024 10:59:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 1 - app/src/main/java/io/legado/app/ui/main/MainActivity.kt | 1 + app/src/main/java/io/legado/app/ui/main/MainViewModel.kt | 6 ++++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 005fca10e8ac..d2dd202286f0 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -84,7 +84,6 @@ class App : Application() { val clearTime = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1) appDb.searchBookDao.clearExpired(clearTime) } - appDb.bookDao.deleteNotShelfBook() RuleBigDataHelp.clearInvalid() BookHelp.clearInvalidCache() Backup.clearCache() diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index 57e6bfa562f5..a8e493bed9f4 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -98,6 +98,7 @@ class MainActivity : VMBaseActivity(), bottomNavigationView.setOnNavigationItemReselectedListener(this@MainActivity) } upHomePage() + viewModel.deleteNotShelfBook() onBackPressedDispatcher.addCallback(this) { if (pagePosition != 0) { binding.viewPagerMain.currentItem = 0 diff --git a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt index fc8d40e0114c..6406ca3313c8 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt @@ -250,4 +250,10 @@ class MainViewModel(application: Application) : BaseViewModel(application) { } } + fun deleteNotShelfBook() { + execute { + appDb.bookDao.deleteNotShelfBook() + } + } + } \ No newline at end of file From 80a359ba5a0442ae3e5bf905d1e9ca1f5856ffcd Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Tue, 24 Sep 2024 12:29:14 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/model/analyzeRule/AnalyzeUrl.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index 7b2f87069634..49b95ab10720 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -320,11 +320,16 @@ class AnalyzeUrl( val rateIndex = concurrentRate.indexOf("/") var fetchRecord = concurrentRecordMap[source.getKey()] if (fetchRecord == null) { - fetchRecord = ConcurrentRecord(rateIndex > 0, System.currentTimeMillis(), 1) - concurrentRecordMap[source.getKey()] = fetchRecord - return fetchRecord + synchronized(concurrentRecordMap) { + fetchRecord = concurrentRecordMap[source.getKey()] + if (fetchRecord == null) { + fetchRecord = ConcurrentRecord(rateIndex > 0, System.currentTimeMillis(), 1) + concurrentRecordMap[source.getKey()] = fetchRecord + return fetchRecord + } + } } - val waitTime: Int = synchronized(fetchRecord) { + val waitTime: Int = synchronized(fetchRecord!!) { try { if (!fetchRecord.isConcurrent) { //并发控制非 次数/毫秒