feat(offline_download): try to init client if not ready (close #4674)

pull/4522/head
Andy Hsu 2023-07-03 22:57:42 +08:00
parent 12f40608e6
commit 59dbf4496f
2 changed files with 20 additions and 4 deletions

View File

@ -48,8 +48,16 @@ func AddAria2(c *gin.Context) {
return
}
if !aria2.IsAria2Ready() {
common.ErrorStrResp(c, "aria2 not ready", 500)
return
// try to init client
_, err := aria2.InitClient(2)
if err != nil {
common.ErrorResp(c, err, 500)
return
}
if !aria2.IsAria2Ready() {
common.ErrorStrResp(c, "aria2 still not ready after init", 500)
return
}
}
var req AddAria2Req
if err := c.ShouldBind(&req); err != nil {

View File

@ -47,8 +47,16 @@ func AddQbittorrent(c *gin.Context) {
return
}
if !qbittorrent.IsQbittorrentReady() {
common.ErrorStrResp(c, "qbittorrent not ready", 500)
return
// try to init client
err := qbittorrent.InitClient()
if err != nil {
common.ErrorResp(c, err, 500)
return
}
if !qbittorrent.IsQbittorrentReady() {
common.ErrorStrResp(c, "qbittorrent still not ready after init", 500)
return
}
}
var req AddQbittorrentReq
if err := c.ShouldBind(&req); err != nil {