Skip to content

Commit

Permalink
feat(offline_download): try to init client if not ready (close #4674)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jul 3, 2023
1 parent 12f4060 commit 59dbf44
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions server/handles/aria2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 10 additions & 2 deletions server/handles/qbittorrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 59dbf44

Please sign in to comment.