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.
This commit is contained in:
2026-06-21 16:10:13 +09:00
parent 6c045999f2
commit 6e77cde4cc
5 changed files with 12 additions and 14 deletions

View File

@@ -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 // --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 // request loop, so already-good pieces are not re-requested from peers
// verifies first, then fetches only what is missing). // (verify first, then fetch only what is missing).
if d.opts.CheckIntegrity { if d.opts.CheckIntegrity {
if err := t.VerifyDataContext(ctx); err != nil { if err := t.VerifyDataContext(ctx); err != nil {
return err 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 // 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 — // 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. // 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 // It is not a user-facing flag — 60s is a generous ceiling that a healthy swarm
// generous ceiling that a healthy swarm clears in well under a second. // clears in well under a second.
const metadataTimeout = 60 * time.Second const metadataTimeout = 60 * time.Second
// awaitInfo blocks until the torrent metadata arrives, giving up after // awaitInfo blocks until the torrent metadata arrives, giving up after

View File

@@ -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). // Str returns the raw string value (empty if unset and no default).
func (o *Options) Str(name string) string { return o.vals[name] } func (o *Options) Str(name string) string { return o.vals[name] }
// boolWords is the accepted vocabulary for boolean options. aria2 takes only // boolWords is the accepted vocabulary for boolean options: exactly true and
// true/false (and rejects everything else), so we match it rather than inventing // false, nothing else. boolWord is the single consult point — the Bool reader,
// extra spellings. boolWord is the single consult point — the Bool reader,
// validate(), and the no-conf bootstrap all go through it — so exactly the words // validate(), and the no-conf bootstrap all go through it — so exactly the words
// that validate are honoured. // that validate are honoured.
var boolWords = map[string]bool{ 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. // 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 // Whitespace is trimmed, but case is significant: "True"/"TRUE" are rejected, so
// significant: aria2 rejects "True"/"TRUE", so the match is against exactly // the match is against exactly "true"/"false".
// "true"/"false".
func boolWord(s string) (val, ok bool) { func boolWord(s string) (val, ok bool) {
val, ok = boolWords[strings.TrimSpace(s)] val, ok = boolWords[strings.TrimSpace(s)]
return val, ok return val, ok

View File

@@ -139,8 +139,8 @@ func TestValidateFloatNonNegative(t *testing.T) {
func TestValidateBool(t *testing.T) { func TestValidateBool(t *testing.T) {
b := byLong["enable-dht"] b := byLong["enable-dht"]
// aria2 accepts only literal true/false (case-sensitive) but trims // Only literal true/false are accepted (case-sensitive), with surrounding
// surrounding whitespace; match that exactly. // whitespace trimmed.
for _, ok := range []string{"true", "false", " true ", "false\t"} { for _, ok := range []string{"true", "false", " true ", "false\t"} {
if err := validate(b, ok); err != nil { if err := validate(b, ok); err != nil {
t.Errorf("validate bool %q: %v", ok, err) t.Errorf("validate bool %q: %v", ok, err)

View File

@@ -509,7 +509,7 @@ func httpConfig(opts *cli.Options, single bool, overallDL *rate.Limiter) httpdl.
if single { if single {
out = opts.Str("out") 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 // 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 // `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 // only when the user actually set -x; otherwise let --split drive per-host

View File

@@ -147,7 +147,7 @@ func TestGatherURIsGrouping(t *testing.T) {
// TestHTTPConnDefault locks the parallelism default: a bare `got URL` must use // TestHTTPConnDefault locks the parallelism default: a bare `got URL` must use
// several connections, not one. With -x unset, --split drives the per-host // 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 // 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) { func TestHTTPConnDefault(t *testing.T) {
cfg := func(args ...string) httpdl.Config { cfg := func(args ...string) httpdl.Config {
res, err := cli.Parse(append([]string{"--no-conf"}, args...)) res, err := cli.Parse(append([]string{"--no-conf"}, args...))