Skip to content

fix: submit download tasks sequentially to preserve input order#834

Open
hackeriori wants to merge 1 commit into
mayswind:masterfrom
hackeriori:fix-download-tasks-order
Open

fix: submit download tasks sequentially to preserve input order#834
hackeriori wants to merge 1 commit into
mayswind:masterfrom
hackeriori:fix-download-tasks-order

Conversation

@hackeriori

Copy link
Copy Markdown

Problem

When submitting multiple download links at once (e.g., TV episodes), the order of tasks in aria2's waiting queue becomes scrambled. The task that starts downloading first is not necessarily the first link submitted, forcing users to manually reorder tasks by drag-and-drop.

Root Cause

AriaNg submitted all URLs simultaneously via aria2RpcService.addUriMulti, which calls $q.all(promises) to fire all aria2.addUri RPC requests in parallel. Since all requests reach aria2 at nearly the same time, aria2's internal queue manager may assign GIDs and positions arbitrarily, losing the user's intended order.

Solution

Replace parallel batch submission with sequential chained submission — each task is submitted only after the previous one's response is received, ensuring aria2 receives them in the exact order the user provided.

Changes

  1. src/scripts/services/aria2TaskService.js — Added newUriTasksSequentially method that uses promise chaining (.then()/.catch()) to submit tasks one by one. Aggregates individual responses into a combined response matching the existing callback format. Follows the same pattern already used by the existing retryTasks method.

  2. src/scripts/controllers/new.js — Changed downloadByLinks to call newUriTasksSequentially instead of newUriTasks.


Fixes #833

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.

The order of the waiting queue does not match the submission order when adding multiple URLs

1 participant