fix: panic when torrent not exist

This commit is contained in:
Simon Ding
2024-09-21 21:47:26 +08:00
parent 37dfb0fe94
commit 40c6e2df5c
5 changed files with 98 additions and 48 deletions

View File

@@ -257,7 +257,11 @@ func (c *Client) findEpisodeFilesPreMoving(historyId int) error {
isSingleEpisode := his.EpisodeID > 0
downloadDir := c.db.GetDownloadDir()
task := c.tasks[historyId]
target := filepath.Join(downloadDir, task.Name())
name, err := task.Name()
if err != nil {
return err
}
target := filepath.Join(downloadDir, name)
fi, err := os.Stat(target)
if err != nil {
return errors.Wrapf(err, "read dir %v", target)