feat: add seed ratio display

This commit is contained in:
Simon Ding
2024-08-11 20:41:26 +08:00
parent 5c6ac2c430
commit 5b70badb50
4 changed files with 17 additions and 9 deletions

View File

@@ -15,7 +15,8 @@ import (
type Activity struct {
*ent.History
Progress int `json:"progress"`
Progress int `json:"progress"`
SeedRatio float32 `json:"seed_ratio"`
}
func (s *Server) GetAllActivities(c *gin.Context) (interface{}, error) {
@@ -35,6 +36,7 @@ func (s *Server) GetAllActivities(c *gin.Context) (interface{}, error) {
for id, task := range s.core.GetTasks() {
if h.ID == id && task.Exists() {
a.Progress = task.Progress()
a.SeedRatio = float32(*task.SeedRatio())
}
}
activities = append(activities, a)

View File

@@ -49,7 +49,7 @@ func (c *Client) checkTasks() {
torrent := c.tasks[id]
ok := c.isSeedRatioLimitReached(r.IndexerID, torrent)
if ok {
log.Infof("torrent file seed ratio reached, remove: %v", torrent.Name())
log.Infof("torrent file seed ratio reached, remove: %v, current seed ratio: %v", torrent.Name(), torrent.SeedRatio())
torrent.Remove()
delete(c.tasks, id)
} else {
@@ -138,7 +138,7 @@ func (c *Client) moveCompletedTask(id int) (err1 error) {
//判断是否需要删除本地文件
ok := c.isSeedRatioLimitReached(r.IndexerID, torrent)
if downloadclient.RemoveCompletedDownloads && ok {
log.Debugf("download complete,remove torrent and files related")
log.Debugf("download complete,remove torrent and files related, torrent: %v, seed ratio: %v", torrentName, torrent.SeedRatio())
delete(c.tasks, r.ID)
torrent.Remove()
}