fix: double downloading status problem

This commit is contained in:
Simon Ding
2024-09-20 11:40:22 +08:00
parent c535dfd714
commit 8af3ffccd3
2 changed files with 9 additions and 6 deletions

View File

@@ -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
}