Skip to content

Commit

Permalink
fix: only schedule anidb images if the entry's image path is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Dec 25, 2024
1 parent a6a5c54 commit f76efe8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Shoko.Server/Scheduling/Jobs/AniDB/GetAniDBCreatorJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public override async Task Process()
RepoFactory.AnimeStaff.Save(staff);
}

if (!string.IsNullOrEmpty(creator.ImagePath) && (!creator.GetImageMetadata()?.IsLocalAvailable ?? false))
if (!(creator.GetImageMetadata()?.IsLocalAvailable ?? true))
{
_logger.LogInformation("Image not found locally, queuing image download for {Creator} (ID={CreatorID},Type={Type})", response.Name, response.ID, response.Type.ToString());
var scheduler = await _schedulerFactory.GetScheduler().ConfigureAwait(false);
Expand Down
21 changes: 10 additions & 11 deletions Shoko.Server/Scheduling/Jobs/Shoko/ValidateAllImagesJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override async Task Process()
UpdateProgress(" - AniDB Posters");
_logger.LogInformation(ScanForType, "AniDB posters");
var animeList = RepoFactory.AniDB_Anime.GetAll()
.Where(anime => !anime.GetImageMetadata().IsLocalAvailable)
.Where(anime => !string.IsNullOrEmpty(anime.Picname) && !anime.GetImageMetadata().IsLocalAvailable)
.ToList();

_logger.LogInformation(FoundCorruptedOfType, animeList.Count, animeList.Count == 1 ? "AniDB poster" : "AniDB posters");
Expand All @@ -94,7 +94,7 @@ public override async Task Process()
UpdateProgress(" - AniDB Characters");
_logger.LogInformation(ScanForType, "AniDB characters");
var characters = RepoFactory.AniDB_Character.GetAll()
.Where(character => !Misc.IsImageValid(character.GetFullImagePath()))
.Where(character => !(character.GetImageMetadata()?.IsLocalAvailable ?? true))
.ToList();

_logger.LogInformation(FoundCorruptedOfType, characters.Count, characters.Count == 1 ? "AniDB Character" : "AniDB Characters");
Expand All @@ -113,19 +113,18 @@ public override async Task Process()
count = 0;
UpdateProgress(" - AniDB Creators");
_logger.LogInformation(ScanForType, "AniDB Creator");
var staff = RepoFactory.AniDB_Creator.GetAll()
.Where(va => !Misc.IsImageValid(va.GetFullImagePath()))
var creators = RepoFactory.AniDB_Creator.GetAll()
.Where(creator => !(creator.GetImageMetadata()?.IsLocalAvailable ?? true))
.ToList();

_logger.LogInformation(FoundCorruptedOfType, staff.Count, "AniDB Creator");
foreach (var seiyuu in staff)
_logger.LogInformation(FoundCorruptedOfType, creators.Count, "AniDB Creator");
foreach (var creator in creators)
{
_logger.LogTrace(CorruptImageFound, seiyuu.GetFullImagePath());
await RemoveImageAndQueueDownload<DownloadAniDBImageJob>(ImageEntityType.Person, seiyuu.CreatorID);
_logger.LogTrace(CorruptImageFound, creator.GetFullImagePath());
await RemoveImageAndQueueDownload<DownloadAniDBImageJob>(ImageEntityType.Person, creator.CreatorID);
if (++count % 10 != 0) continue;
_logger.LogInformation(ReQueueingForDownload, count,
staff.Count);
UpdateProgress($" - AniDB Creators - {count}/{staff.Count}");
_logger.LogInformation(ReQueueingForDownload, count, creators.Count);
UpdateProgress($" - AniDB Creators - {count}/{creators.Count}");
}
}
}
Expand Down

0 comments on commit f76efe8

Please sign in to comment.