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:
8
bt/bt.go
8
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
2
main.go
2
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
|
||||
|
||||
@@ -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...))
|
||||
|
||||
Reference in New Issue
Block a user