Skip to content

Commit

Permalink
refactor(cmd): move pool flag to global set
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Sep 9, 2023
1 parent 4190b6f commit 37dc867
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions app/dl/dl.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type Options struct {
Exclude []string
Desc bool
Takeout bool
PoolSize int64

// resume opts
Continue, Restart bool
Expand All @@ -52,7 +51,7 @@ func Run(ctx context.Context, opts *Options) error {
}

return tgc.RunWithAuth(ctx, c, func(ctx context.Context) (rerr error) {
pool := dcpool.NewPool(c, opts.PoolSize, floodwait.NewSimpleWaiter())
pool := dcpool.NewPool(c, int64(viper.GetInt(consts.FlagPoolSize)), floodwait.NewSimpleWaiter())
defer multierr.AppendInvoke(&rerr, multierr.Close(pool))

parsers := []parser{
Expand Down
1 change: 0 additions & 1 deletion cmd/dl.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func NewDownload() *cobra.Command {
// do not match extension, because some files' extension is corrected by --rewrite-ext flag
cmd.Flags().BoolVar(&opts.SkipSame, "skip-same", false, "skip files with the same name(without extension) and size")

cmd.Flags().Int64Var(&opts.PoolSize, "pool", 3, "specify the size of the DC pool")
cmd.Flags().BoolVar(&opts.Desc, "desc", false, "download files from the newest to the oldest ones (may affect resume download)")
cmd.Flags().BoolVar(&opts.Takeout, "takeout", false, "takeout sessions let you export data from your account with lower flood wait limits.")

Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func New() *cobra.Command {
cmd.PersistentFlags().IntP(consts.FlagPartSize, "s", 512*1024, "part size for transfer, max is 512*1024")
cmd.PersistentFlags().IntP(consts.FlagThreads, "t", 4, "max threads for transfer one item")
cmd.PersistentFlags().IntP(consts.FlagLimit, "l", 2, "max number of concurrent tasks")
cmd.PersistentFlags().Int(consts.FlagPoolSize, 3, "specify the size of the DC pool")

cmd.PersistentFlags().String(consts.FlagNTP, "", "ntp server host, if not set, use system time")
cmd.PersistentFlags().Duration(consts.FlagReconnectTimeout, 2*time.Minute, "Telegram client reconnection backoff timeout, infinite if set to 0") // #158
Expand Down
1 change: 1 addition & 0 deletions pkg/consts/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const (
FlagPartSize = "size"
FlagThreads = "threads"
FlagLimit = "limit"
FlagPoolSize = "pool"
FlagNTP = "ntp"
FlagReconnectTimeout = "reconnect-timeout"
FlagDlTemplate = "template"
Expand Down

0 comments on commit 37dc867

Please sign in to comment.