mirror of
https://github.com/simon-ding/polaris.git
synced 2026-05-06 02:27:35 +08:00
feat: support reload qbit tasks
This commit is contained in:
@@ -105,12 +105,15 @@ type Torrent struct {
|
||||
Config
|
||||
}
|
||||
|
||||
func (t *Torrent) reloadClient() error {
|
||||
func (t *Torrent) Reload() error {
|
||||
c, err := NewClient(t.Config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
t.c = c.c
|
||||
if !t.Exists() {
|
||||
return errors.Errorf("torrent not exists: %v", t.Hash)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -211,18 +214,3 @@ func (t *Torrent) Save() string {
|
||||
func (t *Torrent) GetHash() string {
|
||||
return t.Hash
|
||||
}
|
||||
|
||||
|
||||
func ReloadTorrent(s string) (*Torrent, error) {
|
||||
var torrent = Torrent{}
|
||||
err := json.Unmarshal([]byte(s), &torrent)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = torrent.reloadClient()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "reload client")
|
||||
}
|
||||
return &torrent, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user