This commit is contained in:
Simon Ding
2024-07-12 16:28:46 +08:00
parent 7597e6a147
commit 5ddac22d10
4 changed files with 6 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ type Torrent interface {
Progress() int
Stop() error
Start() error
Remove(deleteData bool) error
Remove() error
Save() string
Exists() bool
}

View File

@@ -106,10 +106,10 @@ func (t *Torrent) Start() error {
return t.c.TorrentStartIDs(context.TODO(), []int64{t.ID})
}
func (t *Torrent) Remove(deleteData bool) error {
func (t *Torrent) Remove() error {
return t.c.TorrentRemove(context.TODO(), transmissionrpc.TorrentRemovePayload{
IDs: []int64{t.ID},
DeleteLocalData: deleteData,
DeleteLocalData: true,
})
}

View File

@@ -27,7 +27,7 @@ func (s *Server) RemoveActivity(c *gin.Context) (interface{}, error) {
}
torrent := s.tasks[his.ID]
if torrent != nil {
if err := torrent.Remove(true); err != nil {
if err := torrent.Remove(); err != nil {
return nil, errors.Wrap(err, "remove torrent")
}
delete(s.tasks, his.ID)

View File

@@ -43,8 +43,7 @@ func (s *Server) moveCompletedTask(id int) error {
torrent := s.tasks[id]
r := s.db.GetHistory(id)
s.db.SetHistoryComplete(r.ID)
tt := s.tasks[r.ID]
tt.Remove(false)
delete(s.tasks, r.ID)
series := s.db.GetSeriesDetails(r.SeriesID)
@@ -67,5 +66,6 @@ func (s *Server) moveCompletedTask(id int) error {
}
log.Infof("move downloaded files to target dir success, file: %v, target dir: %v", torrent.Name(), r.TargetDir)
torrent.Remove()
return nil
}