mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-07 02:27:40 +08:00
feat: show seed as active
This commit is contained in:
@@ -24,21 +24,24 @@ func (s *Server) GetAllActivities(c *gin.Context) (interface{}, error) {
|
|||||||
his := s.db.GetHistories()
|
his := s.db.GetHistories()
|
||||||
var activities = make([]Activity, 0, len(his))
|
var activities = make([]Activity, 0, len(his))
|
||||||
for _, h := range his {
|
for _, h := range his {
|
||||||
if q == "active" && (h.Status != history.StatusRunning && h.Status != history.StatusUploading) {
|
if q == "archive" && (h.Status == history.StatusRunning || h.Status == history.StatusUploading) {
|
||||||
continue //active downloads
|
|
||||||
} else if q == "archive" && (h.Status == history.StatusRunning || h.Status == history.StatusUploading) {
|
|
||||||
continue //archived downloads
|
continue //archived downloads
|
||||||
}
|
}
|
||||||
|
|
||||||
a := Activity{
|
a := Activity{
|
||||||
History: h,
|
History: h,
|
||||||
}
|
}
|
||||||
|
existInDownloadClient := false
|
||||||
for id, task := range s.core.GetTasks() {
|
for id, task := range s.core.GetTasks() {
|
||||||
if h.ID == id && task.Exists() {
|
if h.ID == id && task.Exists() {
|
||||||
a.Progress = task.Progress()
|
a.Progress = task.Progress()
|
||||||
a.SeedRatio = float32(*task.SeedRatio())
|
a.SeedRatio = float32(*task.SeedRatio())
|
||||||
|
existInDownloadClient = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if q == "active" && !existInDownloadClient {
|
||||||
|
continue
|
||||||
|
}
|
||||||
activities = append(activities, a)
|
activities = append(activities, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func (c *Client) checkTasks() {
|
|||||||
torrent.Remove()
|
torrent.Remove()
|
||||||
delete(c.tasks, id)
|
delete(c.tasks, id)
|
||||||
} else {
|
} 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
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,16 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
|
|||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
));
|
));
|
||||||
} else if (ac.status == "success") {
|
} else if (ac.status == "success") {
|
||||||
|
if (ac.progress == 100) {
|
||||||
|
//seeding
|
||||||
|
return const Tooltip(
|
||||||
|
message: "做种中",
|
||||||
|
child: Icon(
|
||||||
|
Icons.upload,
|
||||||
|
//color: Colors.blue,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
return const Tooltip(
|
return const Tooltip(
|
||||||
message: "下载成功",
|
message: "下载成功",
|
||||||
child: Icon(
|
child: Icon(
|
||||||
@@ -118,7 +128,9 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
|
|||||||
children: [
|
children: [
|
||||||
Text("开始时间:${timeago.format(ac.date!)}"),
|
Text("开始时间:${timeago.format(ac.date!)}"),
|
||||||
Text("大小:${(ac.size ?? 0).readableFileSize()}"),
|
Text("大小:${(ac.size ?? 0).readableFileSize()}"),
|
||||||
ac.seedRatio > 0 ?Text("分享率:${ac.seedRatio}"): SizedBox()
|
ac.seedRatio > 0
|
||||||
|
? Text("分享率:${ac.seedRatio}")
|
||||||
|
: SizedBox()
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user