diff --git a/pkg/transmission/transmission.go b/pkg/transmission/transmission.go index 3f1d8f8..09ddc2a 100644 --- a/pkg/transmission/transmission.go +++ b/pkg/transmission/transmission.go @@ -53,7 +53,7 @@ func (c *Client) GetAll() ([]*Torrent, error) { var torrents []*Torrent for _, t := range all { torrents = append(torrents, &Torrent{ - ID: *t.ID, + Hash: *t.HashString, c: c.c, Config: c.cfg, }) @@ -86,12 +86,12 @@ func (c *Client) Download(link, dir string) (*Torrent, error) { DownloadDir: &dir, }) log.Infof("get torrent info: %+v", t) - if t.ID == nil { + if t.HashString == nil { return nil, fmt.Errorf("download torrent error: %v", link) } return &Torrent{ - ID: *t.ID, + Hash: *t.HashString, c: c.c, Config: c.cfg, }, err @@ -100,7 +100,7 @@ func (c *Client) Download(link, dir string) (*Torrent, error) { type Torrent struct { //t *transmissionrpc.Torrent c *transmissionrpc.Client - ID int64 `json:"id"` + Hash string `json:"hash"` Config } @@ -114,7 +114,7 @@ func (t *Torrent) reloadClient() error { } func (t *Torrent) getTorrent() transmissionrpc.Torrent { - r, err := t.c.TorrentGetAllFor(context.TODO(), []int64{t.ID}) + r, err := t.c.TorrentGetAllForHashes(context.TODO(), []string{t.Hash}) if err != nil { log.Errorf("get torrent info for error: %v", err) } @@ -122,7 +122,7 @@ func (t *Torrent) getTorrent() transmissionrpc.Torrent { } func (t *Torrent) Exists() bool { - r, err := t.c.TorrentGetAllFor(context.TODO(), []int64{t.ID}) + r, err := t.c.TorrentGetAllForHashes(context.TODO(), []string{t.Hash}) if err != nil { log.Errorf("get torrent info for error: %v", err) } @@ -155,7 +155,7 @@ func (t *Torrent) Progress() int { } func (t *Torrent) Stop() error { - return t.c.TorrentStopIDs(context.TODO(), []int64{t.ID}) + return t.c.TorrentStopHashes(context.TODO(), []string{t.Hash}) } func (t *Torrent) SeedRatio() *float64 { @@ -163,12 +163,13 @@ func (t *Torrent) SeedRatio() *float64 { } func (t *Torrent) Start() error { - return t.c.TorrentStartIDs(context.TODO(), []int64{t.ID}) + return t.c.TorrentStartHashes(context.TODO(), []string{t.Hash}) } func (t *Torrent) Remove() error { + tt := t.getTorrent() return t.c.TorrentRemove(context.TODO(), transmissionrpc.TorrentRemovePayload{ - IDs: []int64{t.ID}, + IDs: []int64{*tt.ID}, DeleteLocalData: true, }) } diff --git a/server/activity.go b/server/activity.go index c27e78a..a9672e9 100644 --- a/server/activity.go +++ b/server/activity.go @@ -107,7 +107,7 @@ func (s *Server) GetMediaDownloadHistory(c *gin.Context) (interface{}, error) { type TorrentInfo struct { Name string `json:"name"` - ID int64 `json:"id"` + ID string `json:"id"` SeedRatio float32 `json:"seed_ratio"` Progress int `json:"progress"` } @@ -128,7 +128,7 @@ func (s *Server) GetAllTorrents(c *gin.Context) (interface{}, error) { } infos = append(infos, TorrentInfo{ Name: t.Name(), - ID: t.ID, + ID: t.Hash, Progress: t.Progress(), }) } diff --git a/ui/lib/activity.dart b/ui/lib/activity.dart index 485e831..8d6f3a5 100644 --- a/ui/lib/activity.dart +++ b/ui/lib/activity.dart @@ -155,7 +155,7 @@ class _ActivityPageState extends ConsumerState ); } - Function(int) onDelete() { + Function(String) onDelete() { return (id) { final f = ref .read(activitiesDataProvider("active").notifier) diff --git a/ui/lib/providers/activity.dart b/ui/lib/providers/activity.dart index 5a493c3..57832ad 100644 --- a/ui/lib/providers/activity.dart +++ b/ui/lib/providers/activity.dart @@ -47,7 +47,7 @@ class ActivityData extends AutoDisposeFamilyAsyncNotifier, String return activities; } - Future deleteActivity(int id) async { + Future deleteActivity(String id) async { final dio = await APIs.getDio(); var resp = await dio.delete("${APIs.activityUrl}$id"); final sp = ServerResponse.fromJson(resp.data); @@ -72,7 +72,7 @@ class Activity { required this.size, required this.seedRatio}); - final int? id; + final String? id; final int? mediaId; final int? episodeId; final String? sourceTitle;