mirror of https://github.com/Xhofe/alist
feat(offline_download): try to init client if not ready (close #4674)
parent
12f40608e6
commit
59dbf4496f
|
@ -48,9 +48,17 @@ func AddAria2(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !aria2.IsAria2Ready() {
|
if !aria2.IsAria2Ready() {
|
||||||
common.ErrorStrResp(c, "aria2 not ready", 500)
|
// try to init client
|
||||||
|
_, err := aria2.InitClient(2)
|
||||||
|
if err != nil {
|
||||||
|
common.ErrorResp(c, err, 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !aria2.IsAria2Ready() {
|
||||||
|
common.ErrorStrResp(c, "aria2 still not ready after init", 500)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
var req AddAria2Req
|
var req AddAria2Req
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
if err := c.ShouldBind(&req); err != nil {
|
||||||
common.ErrorResp(c, err, 400)
|
common.ErrorResp(c, err, 400)
|
||||||
|
|
|
@ -47,9 +47,17 @@ func AddQbittorrent(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !qbittorrent.IsQbittorrentReady() {
|
if !qbittorrent.IsQbittorrentReady() {
|
||||||
common.ErrorStrResp(c, "qbittorrent not ready", 500)
|
// try to init client
|
||||||
|
err := qbittorrent.InitClient()
|
||||||
|
if err != nil {
|
||||||
|
common.ErrorResp(c, err, 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !qbittorrent.IsQbittorrentReady() {
|
||||||
|
common.ErrorStrResp(c, "qbittorrent still not ready after init", 500)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
var req AddQbittorrentReq
|
var req AddQbittorrentReq
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
if err := c.ShouldBind(&req); err != nil {
|
||||||
common.ErrorResp(c, err, 400)
|
common.ErrorResp(c, err, 400)
|
||||||
|
|
Loading…
Reference in New Issue