Skip to content

Commit

Permalink
Fix bug where series were created for related anime
Browse files Browse the repository at this point in the history
  • Loading branch information
da3dsoul committed Mar 15, 2024
1 parent b75f926 commit f68dc83
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Shoko.Server/Scheduling/Jobs/AniDB/GetAniDBAnimeJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public override async Task<SVR_AniDB_Anime> Process()
};
}

var scheduler = await _schedulerFactory.GetScheduler();
var anime = RepoFactory.AniDB_Anime.GetByAnimeID(AnimeID);
var update = RepoFactory.AniDB_AnimeUpdate.GetByAnimeID(AnimeID);
var animeRecentlyUpdated = AnimeRecentlyUpdated(anime, update);
Expand Down Expand Up @@ -110,7 +111,7 @@ public override async Task<SVR_AniDB_Anime> Process()
if (!CacheOnly)
{
// Queue the command to get the data when we're no longer banned if there is no anime record.
await (await _schedulerFactory.GetScheduler()).StartJob<GetAniDBAnimeJob>(c =>
await scheduler.StartJob<GetAniDBAnimeJob>(c =>
{
c.AnimeID = AnimeID;
c.DownloadRelations = DownloadRelations;
Expand Down Expand Up @@ -146,7 +147,6 @@ public override async Task<SVR_AniDB_Anime> Process()
SVR_AniDB_Anime.UpdateStatsByAnimeID(AnimeID);

// update names based on changes
var scheduler = await _schedulerFactory.GetScheduler();

var videoLocals = RepoFactory.CrossRef_File_Episode.GetByAnimeID(AnimeID).Select(a => RepoFactory.VideoLocal.GetByHash(a.Hash)).Where(a => a != null)
.Distinct();
Expand Down Expand Up @@ -304,6 +304,7 @@ private async Task ProcessRelations(ResponseGetAnime response)
if (_settings.AniDb.MaxRelationDepth <= 0) return;
if (RelDepth > _settings.AniDb.MaxRelationDepth) return;
if (!_settings.AutoGroupSeries && !_settings.AniDb.DownloadRelatedAnime) return;
var scheduler = await _schedulerFactory.GetScheduler();

// Queue or process the related series.
foreach (var relation in response.Relations)
Expand All @@ -324,14 +325,14 @@ private async Task ProcessRelations(ResponseGetAnime response)
}

// Append the command to the queue.
await (await _schedulerFactory.GetScheduler()).StartJobNow<GetAniDBAnimeJob>(c =>
await scheduler.StartJobNow<GetAniDBAnimeJob>(c =>
{
c.AnimeID = relation.RelatedAnimeID;
c.DownloadRelations = true;
c.RelDepth = RelDepth + 1;
c.CacheOnly = !ForceRefresh && CacheOnly;
c.ForceRefresh = ForceRefresh;
c.CreateSeriesEntry = ForceRefresh ? CreateSeriesEntry : CreateSeriesEntry && _settings.AniDb.AutomaticallyImportSeries;
c.CreateSeriesEntry = CreateSeriesEntry && _settings.AniDb.AutomaticallyImportSeries;
});
}
}
Expand Down

0 comments on commit f68dc83

Please sign in to comment.