From 6e77cde4ccb762542e160a1fd14868213c2c6f55 Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Sun, 21 Jun 2026 16:10:13 +0900 Subject: [PATCH] all: reword comments to state behavior directly Comments (and one test comment) now describe the rules on their own terms instead of by comparison to another downloader. No behavior change. --- bt/bt.go | 8 ++++---- cli/options.go | 10 ++++------ cli/parse_test.go | 4 ++-- main.go | 2 +- main_test.go | 2 +- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/bt/bt.go b/bt/bt.go index f4199d8..604aaf9 100644 --- a/bt/bt.go +++ b/bt/bt.go @@ -313,8 +313,8 @@ func (d *Download) Run(ctx context.Context) (err error) { } // --check-integrity: re-hash the existing on-disk data BEFORE arming the - // request loop, so already-good pieces are not re-requested from peers (aria2 - // verifies first, then fetches only what is missing). + // request loop, so already-good pieces are not re-requested from peers + // (verify first, then fetch only what is missing). if d.opts.CheckIntegrity { if err := t.VerifyDataContext(ctx); err != nil { return err @@ -376,8 +376,8 @@ func (d *Download) choose(t *torrent.Torrent) error { // metadataTimeout bounds the magnet metadata-fetch phase. A magnet with no // reachable peers — a dead link, or UDP trackers behind a firewall with no DHT — // would otherwise hang forever, so awaitInfo gives up after this fixed window. -// It is not a user-facing flag: aria2 has no --bt-metadata-timeout, and 60s is a -// generous ceiling that a healthy swarm clears in well under a second. +// It is not a user-facing flag — 60s is a generous ceiling that a healthy swarm +// clears in well under a second. const metadataTimeout = 60 * time.Second // awaitInfo blocks until the torrent metadata arrives, giving up after diff --git a/cli/options.go b/cli/options.go index afd0a4e..85b6e3d 100644 --- a/cli/options.go +++ b/cli/options.go @@ -27,9 +27,8 @@ func (o *Options) IsSet(name string) bool { return o.set[name] } // Str returns the raw string value (empty if unset and no default). func (o *Options) Str(name string) string { return o.vals[name] } -// boolWords is the accepted vocabulary for boolean options. aria2 takes only -// true/false (and rejects everything else), so we match it rather than inventing -// extra spellings. boolWord is the single consult point — the Bool reader, +// boolWords is the accepted vocabulary for boolean options: exactly true and +// false, nothing else. boolWord is the single consult point — the Bool reader, // validate(), and the no-conf bootstrap all go through it — so exactly the words // that validate are honoured. var boolWords = map[string]bool{ @@ -38,9 +37,8 @@ var boolWords = map[string]bool{ } // boolWord reports a value's truth and whether it is a recognised boolean word. -// Whitespace is trimmed (aria2 strips config values too), but case is -// significant: aria2 rejects "True"/"TRUE", so the match is against exactly -// "true"/"false". +// Whitespace is trimmed, but case is significant: "True"/"TRUE" are rejected, so +// the match is against exactly "true"/"false". func boolWord(s string) (val, ok bool) { val, ok = boolWords[strings.TrimSpace(s)] return val, ok diff --git a/cli/parse_test.go b/cli/parse_test.go index f359e0f..c795096 100644 --- a/cli/parse_test.go +++ b/cli/parse_test.go @@ -139,8 +139,8 @@ func TestValidateFloatNonNegative(t *testing.T) { func TestValidateBool(t *testing.T) { b := byLong["enable-dht"] - // aria2 accepts only literal true/false (case-sensitive) but trims - // surrounding whitespace; match that exactly. + // Only literal true/false are accepted (case-sensitive), with surrounding + // whitespace trimmed. for _, ok := range []string{"true", "false", " true ", "false\t"} { if err := validate(b, ok); err != nil { t.Errorf("validate bool %q: %v", ok, err) diff --git a/main.go b/main.go index b8c17b8..fb1806c 100644 --- a/main.go +++ b/main.go @@ -509,7 +509,7 @@ func httpConfig(opts *cli.Options, single bool, overallDL *rate.Limiter) httpdl. if single { out = opts.Str("out") } - // max-connection-per-server caps connections per host. aria2's default is 1, + // max-connection-per-server caps connections per host. Its default is 1, // which on its own would clamp --split to a single connection, so a bare // `got URL` would download single-threaded. Honor the literal default of 1 // only when the user actually set -x; otherwise let --split drive per-host diff --git a/main_test.go b/main_test.go index e6df4ae..3287444 100644 --- a/main_test.go +++ b/main_test.go @@ -147,7 +147,7 @@ func TestGatherURIsGrouping(t *testing.T) { // TestHTTPConnDefault locks the parallelism default: a bare `got URL` must use // several connections, not one. With -x unset, --split drives the per-host // connection count (capped at the -x ceiling of 16); an explicit -x is honored -// verbatim, including the aria2-faithful -x1 single connection. +// verbatim, including -x1 for a single connection. func TestHTTPConnDefault(t *testing.T) { cfg := func(args ...string) httpdl.Config { res, err := cli.Parse(append([]string{"--no-conf"}, args...))