From ca47f79ecb465d6100c90f950df90cefa67b10d3 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Sun, 27 Apr 2025 10:36:33 +0800 Subject: [PATCH] feat(aria2): patching select file operation is not filtered by existing state (#2294) --- pkg/downloader/aria2/aria2.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/downloader/aria2/aria2.go b/pkg/downloader/aria2/aria2.go index 8070d4f..01e25da 100644 --- a/pkg/downloader/aria2/aria2.go +++ b/pkg/downloader/aria2/aria2.go @@ -234,9 +234,14 @@ func (a *aria2Client) SetFilesToDownload(ctx context.Context, handle *downloader return fmt.Errorf("cannot get task: %w", err) } - selected := lo.SliceToMap(status.Files, func(item downloader.TaskFile) (int, bool) { - return item.Index, true - }) + selected := lo.SliceToMap( + lo.Filter(status.Files, func(item downloader.TaskFile, _ int) bool { + return item.Selected + }), + func(item downloader.TaskFile) (int, bool) { + return item.Index, true + }, + ) for _, arg := range args { if !arg.Download { delete(selected, arg.Index)