mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-06 23:21:00 +08:00
chore: updates
This commit is contained in:
@@ -36,14 +36,21 @@ func (c *Client) mustAddCron(spec string, cmd func()) {
|
||||
func (c *Client) checkTasks() {
|
||||
log.Debug("begin check tasks...")
|
||||
for id, t := range c.tasks {
|
||||
r := c.db.GetHistory(id)
|
||||
if !t.Exists() {
|
||||
log.Infof("task no longer exists: %v", id)
|
||||
|
||||
if r.Status == history.StatusRunning || r.Status == history.StatusUploading {
|
||||
log.Warnf("task is running but no longer available in download client, mark as fail, task name: %s", r.SourceTitle)
|
||||
c.db.SetHistoryStatus(id, history.StatusFail)
|
||||
}
|
||||
|
||||
delete(c.tasks, id)
|
||||
continue
|
||||
}
|
||||
log.Infof("task (%s) percentage done: %d%%", t.Name(), t.Progress())
|
||||
if t.Progress() == 100 {
|
||||
r := c.db.GetHistory(id)
|
||||
|
||||
if r.Status == history.StatusSuccess {
|
||||
//task already success, check seed ratio
|
||||
torrent := c.tasks[id]
|
||||
|
||||
@@ -184,20 +184,21 @@ func searchWithTorznab(db *db.Client, queries ...string) []torznab.Result {
|
||||
if tor.Disabled {
|
||||
continue
|
||||
}
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
log.Debugf("search torznab %v with %v", tor.Name, queries)
|
||||
defer wg.Done()
|
||||
for _, q := range queries {
|
||||
for _, q := range queries {
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
log.Debugf("search torznab %v with %v", tor.Name, queries)
|
||||
defer wg.Done()
|
||||
|
||||
resp, err := torznab.Search(tor, q)
|
||||
if err != nil {
|
||||
log.Warnf("search %s with query %s error: %v", tor.Name, q, err)
|
||||
continue
|
||||
return
|
||||
}
|
||||
resChan <- resp
|
||||
}
|
||||
|
||||
}()
|
||||
}()
|
||||
}
|
||||
}
|
||||
go func() {
|
||||
wg.Wait()
|
||||
|
||||
Reference in New Issue
Block a user