From 27d8b1672a95b1cccea976a7c8331e2dc5ac8a92 Mon Sep 17 00:00:00 2001 From: Simon Ding Date: Sun, 11 Aug 2024 22:40:38 +0800 Subject: [PATCH] feat: show seed as active --- server/activity.go | 9 ++++++--- server/core/scheduler.go | 2 +- ui/lib/activity.dart | 14 +++++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/server/activity.go b/server/activity.go index 99d8f12..3f3c151 100644 --- a/server/activity.go +++ b/server/activity.go @@ -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) } diff --git a/server/core/scheduler.go b/server/core/scheduler.go index 3ad029f..6755b06 100644 --- a/server/core/scheduler.go +++ b/server/core/scheduler.go @@ -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 } diff --git a/ui/lib/activity.dart b/ui/lib/activity.dart index f80cb64..fd7fe57 100644 --- a/ui/lib/activity.dart +++ b/ui/lib/activity.dart @@ -90,6 +90,16 @@ class _ActivityPageState extends ConsumerState color: Colors.red, )); } else if (ac.status == "success") { + if (ac.progress == 100) { + //seeding + return const Tooltip( + message: "做种中", + child: Icon( + Icons.upload, + //color: Colors.blue, + ), + ); + } return const Tooltip( message: "下载成功", child: Icon( @@ -118,7 +128,9 @@ class _ActivityPageState extends ConsumerState children: [ Text("开始时间:${timeago.format(ac.date!)}"), Text("大小:${(ac.size ?? 0).readableFileSize()}"), - ac.seedRatio > 0 ?Text("分享率:${ac.seedRatio}"): SizedBox() + ac.seedRatio > 0 + ? Text("分享率:${ac.seedRatio}") + : SizedBox() ], ), ),