fix: issues

This commit is contained in:
Rogee
2024-09-05 15:51:52 +08:00
parent 568c28d3ab
commit fac2ecdf64
2 changed files with 8 additions and 10 deletions

View File

@@ -37,18 +37,13 @@ func channelExportCmd(ctx context.Context) error {
if pkID == 0 {
return errors.New("db channel id required")
}
channel, err := client.ChannelInfoByID(ctx, pkID)
cfg, err := NewDBChannelFromDB(pkID)
if err != nil {
return err
}
if channel.GetID() == 0 {
return errors.New("channel not found")
}
cfg := NewDBChannel(channel.GetID(), channel.Username, channel.Title)
if err := cfg.GetOrCreate(ctx); err != nil {
channel, err := client.ChannelInfoByID(ctx, cfg.UUID)
if err != nil {
return err
}
@@ -57,13 +52,16 @@ func channelExportCmd(ctx context.Context) error {
if err := client.Channel(ctx, channel, cfg, false); err != nil {
logger.Error("failed to export channel", zap.Error(err), zap.Int64("uuid", channel.GetID()))
continueRetryTimes++
sleepSeconds := math.Pow(2, float64(continueRetryTimes))
sleepSeconds := math.Pow(2, float64(1+continueRetryTimes))
if sleepSeconds > 128 {
return err
}
logger.Info("retry after", zap.Int("seconds", int(sleepSeconds)))
time.Sleep(time.Second * time.Duration(sleepSeconds))
continue
}
continueRetryTimes = 0
}
}