From 46701a176d481fdce02318faeb886be367560b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=82=85Fox?= Date: Sun, 6 Nov 2022 16:20:09 +0800 Subject: [PATCH] feat(aria2): mark aria2 seeding as complete (#2223) Currently if using aria2 to download a torrent file, it does not consider seeding + active as completed, so the torrent download task only completes as aria2 stops seeding. This commit uses seeder property of TaskInfo, and mark tasks with active status and true seeder as complete. --- internal/aria2/monitor.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/aria2/monitor.go b/internal/aria2/monitor.go index 202a8b93..2a617e43 100644 --- a/internal/aria2/monitor.go +++ b/internal/aria2/monitor.go @@ -105,7 +105,14 @@ func (m *Monitor) Update() (bool, error) { return true, errors.WithMessage(err, "failed to transfer file") case "error": return true, errors.Errorf("failed to download %s, error: %s", m.tsk.ID, info.ErrorMessage) - case "active", "waiting", "paused": + case "active": + m.tsk.SetStatus("aria2: " + info.Status) + if info.Seeder == "true" { + err := m.Complete() + return true, errors.WithMessage(err, "failed to transfer file") + } + return false, nil + case "waiting", "paused": m.tsk.SetStatus("aria2: " + info.Status) return false, nil case "removed":