diff --git a/server/handles/aria2.go b/server/handles/aria2.go index f127bf04..325367a7 100644 --- a/server/handles/aria2.go +++ b/server/handles/aria2.go @@ -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 { diff --git a/server/handles/qbittorrent.go b/server/handles/qbittorrent.go index e99007dc..b2280454 100644 --- a/server/handles/qbittorrent.go +++ b/server/handles/qbittorrent.go @@ -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 {