cmd/torrent: Improve context error handling
This commit is contained in:
parent
23a0e7f7d3
commit
660d73eb9c
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"expvar"
|
||||
"fmt"
|
||||
"io"
|
||||
|
@ -352,7 +351,7 @@ func downloadErr(flags downloadFlags) error {
|
|||
if ctx.Err() == nil {
|
||||
log.Print("downloaded ALL the torrents")
|
||||
} else {
|
||||
err = errors.New("y u no complete torrents?!")
|
||||
err = ctx.Err()
|
||||
}
|
||||
clientConnStats := client.ConnStats()
|
||||
log.Printf("average download rate: %v",
|
||||
|
|
|
@ -37,7 +37,7 @@ func mainErr() error {
|
|||
defer envpprof.Stop()
|
||||
stdLog.SetFlags(stdLog.Flags() | stdLog.Lshortfile)
|
||||
debug := args.Flag(args.FlagOpt{Long: "debug"})
|
||||
args.ParseMain(
|
||||
return args.ParseMain(
|
||||
debug,
|
||||
args.Subcommand("metainfo", metainfoCmd),
|
||||
args.Subcommand("announce", func(p args.SubCmdCtx) error {
|
||||
|
@ -130,5 +130,4 @@ func mainErr() error {
|
|||
}),
|
||||
args.Subcommand("serve", serve, args.Help("creates and seeds a torrent from a filepath")),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -7,7 +7,7 @@ require (
|
|||
github.com/RoaringBitmap/roaring v0.9.4
|
||||
github.com/ajwerner/btree v0.0.0-20211201061316-91c8b66ad617
|
||||
github.com/alexflint/go-arg v1.4.2
|
||||
github.com/anacrolix/args v0.5.0
|
||||
github.com/anacrolix/args v0.5.1-0.20220509024600-c3b77d0b61ac
|
||||
github.com/anacrolix/chansync v0.3.0
|
||||
github.com/anacrolix/dht/v2 v2.16.2-0.20220311024416-dd658f18fd51
|
||||
github.com/anacrolix/envpprof v1.2.1
|
||||
|
|
2
go.sum
2
go.sum
|
@ -28,6 +28,8 @@ github.com/alexflint/go-scalar v1.1.0 h1:aaAouLLzI9TChcPXotr6gUhq+Scr8rl0P9P4Pnl
|
|||
github.com/alexflint/go-scalar v1.1.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o=
|
||||
github.com/anacrolix/args v0.5.0 h1:bZCkbtn4QMB4ow2g34R/oqTFwrI6IojysKop6+ZcOSs=
|
||||
github.com/anacrolix/args v0.5.0/go.mod h1:Fj/N2PehEwTBE5t/V/9xgTcxDkuYQ+5IBoFw/8gkldI=
|
||||
github.com/anacrolix/args v0.5.1-0.20220509024600-c3b77d0b61ac h1:XWoepbk3zgOQ8jMO3vpOnohd6MfENPbFZPivB2L7myc=
|
||||
github.com/anacrolix/args v0.5.1-0.20220509024600-c3b77d0b61ac/go.mod h1:Fj/N2PehEwTBE5t/V/9xgTcxDkuYQ+5IBoFw/8gkldI=
|
||||
github.com/anacrolix/chansync v0.3.0 h1:lRu9tbeuw3wl+PhMu/r+JJCRu5ArFXIluOgdF0ao6/U=
|
||||
github.com/anacrolix/chansync v0.3.0/go.mod h1:DZsatdsdXxD0WiwcGl0nJVwyjCKMDv+knl1q2iBjA2k=
|
||||
github.com/anacrolix/dht/v2 v2.16.2-0.20220311024416-dd658f18fd51 h1:issCwqC43gQ7n0gg9rn0EeVYXnQMI7vlnWub4oidtlU=
|
||||
|
|
Loading…
Reference in New Issue