From 9c7129660c2bf9a5716072475470a91b1e4004e7 Mon Sep 17 00:00:00 2001 From: Simon Ding Date: Wed, 23 Apr 2025 16:43:39 +0800 Subject: [PATCH] feat: seeding torrent only mark as success --- server/activity.go | 9 +++++++++ ui/lib/activity.dart | 21 +++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/server/activity.go b/server/activity.go index 400e5ca..5e7e074 100644 --- a/server/activity.go +++ b/server/activity.go @@ -98,6 +98,15 @@ func (s *Server) RemoveActivity(c *gin.Context) (interface{}, error) { if err := s.core.RemoveTaskAndTorrent(his.ID); err != nil { return nil, errors.Wrap(err, "remove torrent") } + if his.Status == history.StatusSeeding { + //seeding, will mark as complete + log.Infof("history is now seeding, will only mark history as success: (%d) %s", his.ID, his.SourceTitle) + if err := s.db.SetHistoryStatus(his.ID, history.StatusSuccess); err!= nil { + return nil, errors.Wrap(err, "set status") + } + return nil, nil + } + err := s.db.DeleteHistory(in.ID) if err != nil { return nil, errors.Wrap(err, "db") diff --git a/ui/lib/activity.dart b/ui/lib/activity.dart index 5b6172a..acaf670 100644 --- a/ui/lib/activity.dart +++ b/ui/lib/activity.dart @@ -151,19 +151,30 @@ class _ActivityPageState extends ConsumerState children: [ Text("开始时间:${timeago.format(ac.date!)}"), Text("大小:${(ac.size ?? 0).readableFileSize()}"), - (ac.seedRatio??0) > 0 + (ac.seedRatio ?? 0) > 0 ? Text("分享率:${ac.seedRatio}") : SizedBox() ], ), ), - trailing: selectedTab != 2 + trailing: selectedTab == 0 ? IconButton( tooltip: "删除任务", onPressed: () => showConfirmDialog(context, ac.id!), icon: const Icon(Icons.delete)) - : const Text("-"), + : (selectedTab == 1 + ? IconButton( + tooltip: "完成做种", + onPressed: () => { + ref + .read(activitiesDataProvider( + ActivityStatus.active) + .notifier) + .deleteActivity(ac.id!, false) + }, + icon: const Icon(Icons.check)) + : const Text("-")), ), Divider(), ], @@ -234,7 +245,9 @@ class _ActivityPageState extends ConsumerState return ListTile( dense: true, title: Text(item.torrentName ?? ""), - subtitle: Opacity( opacity: 0.7,child: Text("hash: ${item.torrentHash ?? ""}")), + subtitle: Opacity( + opacity: 0.7, + child: Text("hash: ${item.torrentHash ?? ""}")), trailing: IconButton( onPressed: () { final f = ref