Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/downloader manager persisting queue #639

Merged

Conversation

schroda
Copy link
Collaborator

@schroda schroda commented Aug 5, 2023

is rebased onto #638

Comment on lines 155 to 138
saveQueueFlow.flatMapLatest {
saveQueue.acquire()
flow { emit(it) }
}.onEach {
mutex.withLock {
saveDownloadQueue()
saveQueue.release()
}
}.launchIn(scope)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this can just be replaced by using

val saveQueueFlow = MutableSharedFlow(extraBufferCapacity = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST)

instead of this magic

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but everyone needs a little magic in their lives - updated
your-a-wizard-harry

@schroda schroda force-pushed the fix/downloader_manager_persisting_queue branch from 93dcd31 to 55d6ec5 Compare August 6, 2023 00:34
schroda added 4 commits August 6, 2023 02:34
The download queue was never saved after a download was finished.
This caused finished download to be restored on a server start, which caused unnecessary "downloads" which most of the time would just finish immediately since the pages were still in the cache
Since multiple downloaders could be finished at the same time, the download queue should be saved synchronously
This gets called everytime a downloader finished downloading all chapters of its source.
Since the queue is now saved everytime a download is finished, this is trigger is not needed anymore
@schroda schroda force-pushed the fix/downloader_manager_persisting_queue branch from 55d6ec5 to 9e2428a Compare August 6, 2023 00:34
@schroda schroda marked this pull request as draft August 6, 2023 00:46
@schroda schroda marked this pull request as ready for review August 6, 2023 01:00
@Syer10 Syer10 merged commit 2889029 into Suwayomi:master Aug 7, 2023
@schroda schroda deleted the fix/downloader_manager_persisting_queue branch August 8, 2023 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants