chore(forward): pass part size in options

This commit is contained in:
iyear 2023-11-26 14:09:48 +08:00
parent d6159dfbb6
commit d8789f7c74
3 changed files with 5 additions and 6 deletions

View File

@ -86,6 +86,7 @@ func Run(ctx context.Context, opts Options) error {
DryRun: opts.DryRun,
Mode: opts.Mode,
Progress: newProgress(fwProgress),
PartSize: viper.GetInt(consts.FlagPartSize),
})
go fwProgress.Render()

View File

@ -67,8 +67,7 @@ func (f *Forwarder) CloneMedia(ctx context.Context, opts CloneOptions) (tg.Input
return nil
})
err := wg.Wait()
if err != nil {
if err := wg.Wait(); err != nil {
return nil, errors.Wrap(err, "wait")
}

View File

@ -11,10 +11,8 @@ import (
"github.com/gotd/td/telegram/message"
"github.com/gotd/td/telegram/peers"
"github.com/gotd/td/tg"
"github.com/spf13/viper"
"go.uber.org/zap"
"github.com/iyear/tdl/pkg/consts"
"github.com/iyear/tdl/pkg/dcpool"
"github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/tmedia"
@ -41,6 +39,7 @@ type Elem struct {
type Options struct {
Pool dcpool.Pool
PartSize int
Iter Iter
Silent bool
DryRun bool
@ -178,7 +177,7 @@ func (f *Forwarder) forwardMessage(ctx context.Context, from, to peers.Peer, msg
mediaFile, err := f.CloneMedia(ctx, CloneOptions{
Media: media,
PartSize: viper.GetInt(consts.FlagPartSize),
PartSize: f.opts.PartSize,
Progress: uploadProgress{
meta: meta,
progress: f.opts.Progress,
@ -211,7 +210,7 @@ func (f *Forwarder) forwardMessage(ctx context.Context, from, to peers.Peer, msg
thumbFile, err := f.CloneMedia(ctx, CloneOptions{
Media: thumb,
PartSize: viper.GetInt(consts.FlagPartSize),
PartSize: f.opts.PartSize,
Progress: nopProgress{},
})
if err != nil {