diff --git a/server/activity.go b/server/activity.go index a9672e9..e59095c 100644 --- a/server/activity.go +++ b/server/activity.go @@ -68,9 +68,14 @@ 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") } + err = s.db.DeleteHistory(id) + if err != nil { + return nil, errors.Wrap(err, "db") + } + if his.EpisodeID != 0 { - if his.Status == history.StatusRunning || his.Status == history.StatusUploading { + if !s.db.IsEpisodeDownloadingOrDownloaded(his.EpisodeID) { s.db.SetEpisodeStatus(his.EpisodeID, episode.StatusMissing) } @@ -85,10 +90,6 @@ func (s *Server) RemoveActivity(c *gin.Context) (interface{}, error) { } } - err = s.db.DeleteHistory(id) - if err != nil { - return nil, errors.Wrap(err, "db") - } log.Infof("history record successful deleted: %v", his.SourceTitle) return nil, nil } diff --git a/server/core/scheduler.go b/server/core/scheduler.go index c9c7af7..4e7022f 100644 --- a/server/core/scheduler.go +++ b/server/core/scheduler.go @@ -129,7 +129,9 @@ func (c *Client) moveCompletedTask(id int) (err1 error) { if err1 != nil { c.db.SetHistoryStatus(r.ID, history.StatusFail) if r.EpisodeID != 0 { - c.db.SetEpisodeStatus(r.EpisodeID, episode.StatusMissing) + if !c.db.IsEpisodeDownloadingOrDownloaded(r.EpisodeID) { + c.db.SetEpisodeStatus(r.EpisodeID, episode.StatusMissing) + } } else { c.db.SetSeasonAllEpisodeStatus(r.MediaID, seasonNum, episode.StatusMissing) }