feat: check connect before add download client

This commit is contained in:
Simon Ding
2024-07-25 14:19:03 +08:00
parent 520933085d
commit 58e65b21fb
3 changed files with 51 additions and 36 deletions

View File

@@ -28,6 +28,10 @@ func NewClient(c Config) (*Client, error) {
if err != nil {
return nil, errors.Wrap(err, "connect transmission")
}
_, err = tbt.TorrentGetAll(context.TODO())
if err != nil {
return nil, errors.Wrap(err, "transmission cannot connect")
}
return &Client{c: tbt, cfg: c}, nil
}