Skip to content

Commit

Permalink
chore: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-ding committed Aug 11, 2024
1 parent 620f085 commit 349e394
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
9 changes: 8 additions & 1 deletion server/core/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
19 changes: 10 additions & 9 deletions server/core/torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/settings/general.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class _GeneralState extends ConsumerState<GeneralSettings> {
width: 300,
child: FormBuilderSwitch(
decoration:
const InputDecoration(icon: Icon(Icons.filter_alt)),
const InputDecoration(icon: Icon(Icons.phone_iphone)),
name: "allow_qiangban",
title: const Text("是否下载枪版资源")),
),
Expand Down

0 comments on commit 349e394

Please sign in to comment.