feat: show seed as active

This commit is contained in:
Simon Ding
2024-08-11 22:40:38 +08:00
parent 349e394e8e
commit 27d8b1672a
3 changed files with 20 additions and 5 deletions

View File

@@ -24,21 +24,24 @@ func (s *Server) GetAllActivities(c *gin.Context) (interface{}, error) {
his := s.db.GetHistories()
var activities = make([]Activity, 0, len(his))
for _, h := range his {
if q == "active" && (h.Status != history.StatusRunning && h.Status != history.StatusUploading) {
continue //active downloads
} else if q == "archive" && (h.Status == history.StatusRunning || h.Status == history.StatusUploading) {
if q == "archive" && (h.Status == history.StatusRunning || h.Status == history.StatusUploading) {
continue //archived downloads
}
a := Activity{
History: h,
}
existInDownloadClient := false
for id, task := range s.core.GetTasks() {
if h.ID == id && task.Exists() {
a.Progress = task.Progress()
a.SeedRatio = float32(*task.SeedRatio())
existInDownloadClient = true
}
}
if q == "active" && !existInDownloadClient {
continue
}
activities = append(activities, a)
}

View File

@@ -60,7 +60,7 @@ func (c *Client) checkTasks() {
torrent.Remove()
delete(c.tasks, id)
} else {
log.Infof("torrent file still sedding: %v", torrent.Name())
log.Infof("torrent file still sedding: %v, current seed ratio: %v", torrent.Name(), torrent.SeedRatio())
}
continue
}