fix(qbittorrent): fix multiple bugs for qbittorrent download (close #3413 in #3427)

* fix(qbittorrent): wait for qbittorrent to parse torrent and create task

#3413

* fix(qbittorrent): check task state correctly

* fix(qbittorrent): fix path sent to `op.Put()`
This commit is contained in:
kdxcxs
2023-02-15 15:58:31 +08:00
committed by GitHub
parent 6659f6d367
commit d92c10da56
2 changed files with 43 additions and 24 deletions

View File

@ -242,6 +242,19 @@ type TorrentInfo struct {
Upspeed int `json:"upspeed"` // 上传速度(字节/秒)
}
type InfoNotFoundError struct {
Id string
Err error
}
func (i InfoNotFoundError) Error() string {
return "there should be exactly one task with tag \"alist-" + i.Id + "\""
}
func NewInfoNotFoundError(id string) InfoNotFoundError {
return InfoNotFoundError{Id: id}
}
func (c *client) GetInfo(id string) (TorrentInfo, error) {
var infos []TorrentInfo
@ -266,7 +279,7 @@ func (c *client) GetInfo(id string) (TorrentInfo, error) {
return TorrentInfo{}, err
}
if len(infos) != 1 {
return TorrentInfo{}, errors.New("there should be exactly one task with tag \"alist-" + id + "\"")
return TorrentInfo{}, NewInfoNotFoundError(id)
}
return infos[0], nil
}