mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-24 09:45:11 +08:00
fix: will restore episode status after download fail
This commit is contained in:
@@ -84,8 +84,8 @@ lo:
|
||||
if len(episodeNums) == 0 { //want season pack
|
||||
if m.IsSeasonPack {
|
||||
name, err := c.DownloadEpisodeTorrent(r, DownloadOptions{
|
||||
SeasonNum: seasonNum,
|
||||
MediaId: seriesId,
|
||||
SeasonNum: seasonNum,
|
||||
MediaId: seriesId,
|
||||
HashFilterFn: c.hashInBlacklist,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -104,9 +104,9 @@ lo:
|
||||
torrentEpisodes = append(torrentEpisodes, i)
|
||||
}
|
||||
name, err := c.DownloadEpisodeTorrent(r, DownloadOptions{
|
||||
SeasonNum: seasonNum,
|
||||
MediaId: seriesId,
|
||||
EpisodeNums: torrentEpisodes,
|
||||
SeasonNum: seasonNum,
|
||||
MediaId: seriesId,
|
||||
EpisodeNums: torrentEpisodes,
|
||||
HashFilterFn: c.hashInBlacklist,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -135,7 +135,7 @@ func (c *Engine) DownloadMovie(m *ent.Media, r1 torznab.Result) (*string, error)
|
||||
|
||||
func (c *Engine) hashInBlacklist(hash string) bool {
|
||||
blacklist, err := c.db.GetTorrentBlacklist()
|
||||
if err!= nil {
|
||||
if err != nil {
|
||||
log.Warnf("get torrent blacklist error: %v", err)
|
||||
return false
|
||||
}
|
||||
@@ -147,7 +147,7 @@ func (c *Engine) hashInBlacklist(hash string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *Engine) downloadTorrent(m *ent.Media, r1 torznab.Result, op DownloadOptions) (*string, error) {
|
||||
func (c *Engine) downloadTorrent(m *ent.Media, r1 torznab.Result, op DownloadOptions) (s *string, err1 error) {
|
||||
trc, dlc, err := c.GetDownloadClient()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get download client")
|
||||
@@ -176,6 +176,11 @@ func (c *Engine) downloadTorrent(m *ent.Media, r1 torznab.Result, op DownloadOpt
|
||||
}
|
||||
if ep.Status == episode.StatusMissing {
|
||||
c.db.SetEpisodeStatus(ep.ID, episode.StatusDownloading)
|
||||
defer func(episodeId int) {
|
||||
if err1 != nil {
|
||||
c.db.SetEpisodeStatus(episodeId, episode.StatusMissing)
|
||||
}
|
||||
}(ep.ID)
|
||||
}
|
||||
}
|
||||
buff := &bytes.Buffer{}
|
||||
@@ -191,12 +196,23 @@ func (c *Engine) downloadTorrent(m *ent.Media, r1 torznab.Result, op DownloadOpt
|
||||
} else { //season package download
|
||||
name = fmt.Sprintf("全集 (%s)", name)
|
||||
c.db.SetSeasonAllEpisodeStatus(m.ID, op.SeasonNum, episode.StatusDownloading)
|
||||
defer func(mediaId int, seasonNum int) {
|
||||
if err1 != nil {
|
||||
c.db.SetSeasonAllEpisodeStatus(mediaId, seasonNum, episode.StatusMissing)
|
||||
}
|
||||
|
||||
}(m.ID, op.SeasonNum)
|
||||
}
|
||||
|
||||
} else {//movie download
|
||||
} else { //movie download
|
||||
ep, _ := c.db.GetMovieDummyEpisode(m.ID)
|
||||
if ep.Status == episode.StatusMissing {
|
||||
c.db.SetEpisodeStatus(ep.ID, episode.StatusDownloading)
|
||||
defer func(episodeId int) {
|
||||
if err1 != nil {
|
||||
c.db.SetEpisodeStatus(episodeId, episode.StatusMissing)
|
||||
}
|
||||
}(ep.ID)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user