Skip to content

fix(download): support full directory traversal when sending to Aria2#300

Open
himulawang wants to merge 1 commit into
AlistGo:mainfrom
himulawang:main
Open

fix(download): support full directory traversal when sending to Aria2#300
himulawang wants to merge 1 commit into
AlistGo:mainfrom
himulawang:main

Conversation

@himulawang
Copy link
Copy Markdown

Description

The Problem

Currently, when a user selects a directory and clicks "Send To Aria2", Alist only adds the first page of files (default 50) to the Aria2 download queue. Any files beyond the first page are ignored, requiring users to manually add the remaining files, which is inconvenient for large directories.

This occurs because the fetchFolderStructure function in useDownload.ts calls the fsList API without handling pagination, thus only receiving the first response payload.

The Solution

  1. Pagination Loop: Modified fetchFolderStructure to include a while loop that continues to request the next page of the directory content until all files and sub-directories are retrieved.
  2. Settings Integration: Replaced the hardcoded page size with getPagination().size from the settings store. This ensures the "Send To Aria2" functionality respects the default_page_size configured in the Admin settings and adheres to the system's MAX_PAGE_SIZE limit.

Steps to Reproduce

  1. Create or use a directory containing more than 50 files.
  2. Right-click the directory $\rightarrow$ Download $\rightarrow$ Send to Aria2.
  3. Check the Aria2 RPC client (e.g., AriaNg).
  4. Observed Result: Only the first 50 files appear in the queue.
  5. Expected Result: All files within the directory (and its sub-directories) should be added to the queue.

Implementation Details

  • File modified: src/hooks/useDownload.ts
  • Logic change:
    • Introduced a page counter and a while loop inside fetchFolderStructure.
    • Added a break condition: if (content.length < perPage) break;.
    • Integrated getPagination() from ~/store/settings to determine perPage.

Verification & Test Plan

βœ… Manual Testing

  • Large Directory Test: Selected a folder with 120 files $\rightarrow$ Verified all 120 files were sent to Aria2.
  • Recursive Directory Test: Selected a nested folder structure $\rightarrow$ Verified all files in all sub-folders were retrieved.
  • Admin Setting Sync: Changed default_page_size in Admin settings $\rightarrow$ Verified the fs/list request's per_page parameter updated accordingly.

βœ… Technical Verification

  • Network Inspection: Verified via Browser DevTools $\rightarrow$ Network Tab that multiple fs/list requests are triggered with incrementing page parameters (page=1, page=2, etc.) until the full list is fetched.
  • Boundary Test: Verified that the loop terminates correctly when the total number of files is exactly a multiple of the page size.

to the Aria2 queue when selecting a directory.

- Implemented a pagination loop in fetchFolderStructure to recursively
  retrieve all files across all pages.
- Replaced the hardcoded page size with getPagination().size to sync
  with the Admin "default_page_size" setting.
- Ensures that all items in a directory and its sub-directories are
  correctly sent to Aria2 regardless of the total file count.
@netlify
Copy link
Copy Markdown

netlify Bot commented May 3, 2026

βœ… Deploy Preview for alist-web ready!

Name Link
πŸ”¨ Latest commit 2b81781
πŸ” Latest deploy log https://app.netlify.com/projects/alist-web/deploys/69f71d1b3843290008ce049a
😎 Deploy Preview https://deploy-preview-300--alist-web.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
πŸ€– Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

1 participant