mirror of
https://github.com/saltbo/zpan.git
synced 2026-08-28 15:51:29 +08:00
fix(downloader): request uploadLength/uploadSpeed/connections/numSeeders from aria2 tellStatus
aria2's tellStatus only returns the keys it's asked for, but aria2StatusKeys omitted uploadLength, uploadSpeed, connections and numSeeders — while aria2Detail reads status.UploadLength/UploadSpeed/Connections/NumSeeders. So the runtime reported them all as 0: during seeding the Overview showed 0 B/s upload and 0 B uploaded, even though the Peers list had per-peer upload activity (that comes from a separate getPeers call). Confirmed on live aria2: the seeding torrent reported uploadSpeed ~3.26MB/s and uploadLength ~2.5GB when those keys were requested. Adds the missing keys + a guard test.
This commit is contained in:
@@ -57,6 +57,10 @@ var aria2StatusKeys = []string{
|
||||
"totalLength",
|
||||
"completedLength",
|
||||
"downloadSpeed",
|
||||
"uploadLength",
|
||||
"uploadSpeed",
|
||||
"connections",
|
||||
"numSeeders",
|
||||
"dir",
|
||||
"files",
|
||||
"bittorrent",
|
||||
|
||||
@@ -170,6 +170,25 @@ func TestAria2StartArgsSetsMaxConcurrentDownloads(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAria2StatusKeysCoverReportedFields(t *testing.T) {
|
||||
// aria2's tellStatus only returns the keys it's asked for. aria2Detail reads
|
||||
// these fields, so they must be requested or the runtime reports zeros
|
||||
// (e.g. seeding upload speed/total showing 0 while peers upload).
|
||||
required := []string{
|
||||
"status", "totalLength", "completedLength", "downloadSpeed",
|
||||
"uploadLength", "uploadSpeed", "connections", "numSeeders",
|
||||
}
|
||||
have := map[string]bool{}
|
||||
for _, key := range aria2StatusKeys {
|
||||
have[key] = true
|
||||
}
|
||||
for _, key := range required {
|
||||
if !have[key] {
|
||||
t.Fatalf("aria2StatusKeys missing %q — tellStatus won't return it, so aria2Detail reports 0", key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAria2SeedTimeMinutes(t *testing.T) {
|
||||
if got := aria2SeedTimeMinutes(time.Hour); got != 60 {
|
||||
t.Fatalf("expected 1h to map to 60 minutes, got %d", got)
|
||||
|
||||
Reference in New Issue
Block a user