misc update

This commit is contained in:
Simon Ding
2024-07-11 12:19:35 +08:00
parent 7c2ae26efe
commit a172ca0361
10 changed files with 473 additions and 199 deletions

View File

@@ -7,6 +7,7 @@ type Torrent interface {
Start() error
Remove() error
Save() string
Exists() bool
}

View File

@@ -59,6 +59,14 @@ func (t *Torrent) getTorrent() transmissionrpc.Torrent {
return r[0]
}
func (t *Torrent) Exists() bool {
r, err := t.c.TorrentGetAllFor(context.TODO(), []int64{t.id})
if err != nil {
log.Errorf("get torrent info for error: %v", err)
}
return len(r) > 0
}
func (t *Torrent) Name() string {
return *t.getTorrent().Name
}
@@ -91,3 +99,4 @@ func (t *Torrent) Remove() error {
func (t *Torrent) Save() string {
return strconv.Itoa(int(t.id))
}