Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
niu-hb committed Sep 25, 2024
2 parents dd420d3 + 0fb1d02 commit d7d89a2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
1 change: 0 additions & 1 deletion app/src/main/java/io/legado/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/legado/app/model/CacheBook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
13 changes: 9 additions & 4 deletions app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
//并发控制非 次数/毫秒
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/io/legado/app/ui/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
bottomNavigationView.setOnNavigationItemReselectedListener(this@MainActivity)
}
upHomePage()
viewModel.deleteNotShelfBook()
onBackPressedDispatcher.addCallback(this) {
if (pagePosition != 0) {
binding.viewPagerMain.currentItem = 0
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/io/legado/app/ui/main/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,10 @@ class MainViewModel(application: Application) : BaseViewModel(application) {
}
}

fun deleteNotShelfBook() {
execute {
appDb.bookDao.deleteNotShelfBook()
}
}

}

0 comments on commit d7d89a2

Please sign in to comment.