Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix API pause_all and resume_all methods
These methods were previously making use of API.pause and API.resume respectively, with the list of all downloads. It was problematic for a few reasons: - trying to pause an already paused download, or to resume an already active one does not make sense. Since we paused or resumed all downloads at once, the result of pause_all or resume_all would be False if even one download was already paused/active. - second, pausing downloads one after the other, non-atomically, was was giving time to aria2 to start waiting downloads, which was not a desired effect. Until now, the pausing/starting was always done in such an order that all downloads were paused at the end, but I cannot ensure it behaves as such in all cases, even if we changed the code to use a batch call or a multicall. It was also generating noise when listening to notifications through a WebSocket. - third, and this might be a direct consequence of the second point, the download queue order, or priority queue, was changed when using pause_all and/or resume_all. Using the native pauseAll and unpauseAll methods of the RPC API, the queue order now stays the same, and API.pause_all and API.resume_all behave as expected, returning proper results (i.e. always True or exception raised).
- Loading branch information