mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-21 18:51:49 +01:00
3ae1e37c40
* Rename removeFromQueueByPredicate to removeFromQueueIf Follow-up to PR comment in #9511 * Make Download hashCode stable Mutating pages would previously change the Download hashCode, which breaks HashMap lookups. * Convert Donwloader subscription to coroutine Replace downloadsRelay with activeDownloadsFlow. Instead of managing a PublishRelay independent from the queue, derive a Flow of active downloads directly from the queue StateFlow. (This will allow updating the queue without pausing the downloader, to be done in a follow-up PR.) When a download completes successfully, the downloads is removed from queueState. This updates activeDownloadsFlow and causes the downloaderJob start the download job for the next active download. When a download fails, the download is left in the queue, so queueState is not modified. To make activeDownloadsFlow update without a change to queueState, use transformLatest and use the Download statusFlows to suspend until a download reaches the ERROR state. To avoid stopping and starting downloads every time activeDownloadsFlow emits a new value, maintain a map of current download Jobs and only start/stop jobs in the difference between downloadJobs and activeDownloads. To make sure all child download jobs are cancelled when the top-level downloader job is cancelled, use supervisorScope. * Remove obsolete main thread references in Downloader Thread safety of the queue state used to be guaranteed by running all queue mutation on the main thread, but this has not been true for some time. Since the queue state is now backed by a StateFlow, queueState can be safely updated by any thread. |
||
---|---|---|
.. | ||
src | ||
.gitignore | ||
build.gradle.kts | ||
proguard-android-optimize.txt | ||
proguard-rules.pro | ||
shortcuts.xml |