aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2026-01-17 13:07:01 +0100
committerShadowghost <Ghost_of_Stone@web.de>2026-01-18 19:45:39 +0100
commit1c1447362efb39b086a4fcaa1f3ece694f4d749a (patch)
tree94415e7d69472299d68d73e62d795fed598409a5
parentd1c97b8e1d58cff3dd7158718a8129a0d84112ca (diff)
Skip metadata refresh for already-indexed items during validation
Optimizes the validation process by checking if items already exist in the database before attempting to refresh metadata.
-rw-r--r--Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs15
-rw-r--r--Emby.Server.Implementations/Library/Validators/GenresValidator.cs15
-rw-r--r--Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs17
-rw-r--r--Emby.Server.Implementations/Library/Validators/StudiosValidator.cs15
4 files changed, 53 insertions, 9 deletions
diff --git a/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs b/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs
index 7cc851b73b..8de3bff7ab 100644
--- a/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs
+++ b/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs
@@ -50,21 +50,28 @@ public class ArtistsValidator
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
var names = _itemRepo.GetAllArtistNames();
+ var existingArtistIds = _libraryManager.GetItemIds(new InternalItemsQuery
+ {
+ IncludeItemTypes = [BaseItemKind.MusicArtist]
+ }).ToHashSet();
var numComplete = 0;
var count = names.Count;
+ var refreshed = 0;
foreach (var name in names)
{
try
{
var item = _libraryManager.GetArtist(name);
-
- await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ if (!existingArtistIds.Contains(item.Id))
+ {
+ await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ refreshed++;
+ }
}
catch (OperationCanceledException)
{
- // Don't clutter the log
throw;
}
catch (Exception ex)
@@ -80,6 +87,8 @@ public class ArtistsValidator
progress.Report(percent);
}
+ _logger.LogInformation("Refreshed metadata for {RefreshedCount} new artists out of {TotalCount} total", refreshed, count);
+
var deadEntities = _libraryManager.GetItemList(new InternalItemsQuery
{
IncludeItemTypes = [BaseItemKind.MusicArtist],
diff --git a/Emby.Server.Implementations/Library/Validators/GenresValidator.cs b/Emby.Server.Implementations/Library/Validators/GenresValidator.cs
index fbfc9f7d54..09ede8bb8d 100644
--- a/Emby.Server.Implementations/Library/Validators/GenresValidator.cs
+++ b/Emby.Server.Implementations/Library/Validators/GenresValidator.cs
@@ -1,5 +1,6 @@
using System;
using System.Globalization;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Enums;
@@ -48,17 +49,25 @@ public class GenresValidator
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
var names = _itemRepo.GetGenreNames();
+ var existingGenreIds = _libraryManager.GetItemIds(new InternalItemsQuery
+ {
+ IncludeItemTypes = [BaseItemKind.Genre]
+ }).ToHashSet();
var numComplete = 0;
var count = names.Count;
+ var refreshed = 0;
foreach (var name in names)
{
try
{
var item = _libraryManager.GetGenre(name);
-
- await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ if (!existingGenreIds.Contains(item.Id))
+ {
+ await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ refreshed++;
+ }
}
catch (OperationCanceledException)
{
@@ -78,6 +87,8 @@ public class GenresValidator
progress.Report(percent);
}
+ _logger.LogInformation("Refreshed metadata for {RefreshedCount} new genres out of {TotalCount} total", refreshed, count);
+
var deadEntities = _libraryManager.GetItemList(new InternalItemsQuery
{
IncludeItemTypes = [BaseItemKind.Genre, BaseItemKind.MusicGenre],
diff --git a/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs b/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs
index 6203bce2bc..4365707529 100644
--- a/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs
+++ b/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs
@@ -1,6 +1,9 @@
using System;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Data.Enums;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using Microsoft.Extensions.Logging;
@@ -45,17 +48,25 @@ public class MusicGenresValidator
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
var names = _itemRepo.GetMusicGenreNames();
+ var existingMusicGenreIds = _libraryManager.GetItemIds(new InternalItemsQuery
+ {
+ IncludeItemTypes = [BaseItemKind.MusicGenre]
+ }).ToHashSet();
var numComplete = 0;
var count = names.Count;
+ var refreshed = 0;
foreach (var name in names)
{
try
{
var item = _libraryManager.GetMusicGenre(name);
-
- await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ if (!existingMusicGenreIds.Contains(item.Id))
+ {
+ await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ refreshed++;
+ }
}
catch (OperationCanceledException)
{
@@ -75,6 +86,8 @@ public class MusicGenresValidator
progress.Report(percent);
}
+ _logger.LogInformation("Refreshed metadata for {RefreshedCount} new music genres out of {TotalCount} total", refreshed, count);
+
progress.Report(100);
}
}
diff --git a/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs b/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs
index 5b87e4d9d0..dd124feece 100644
--- a/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs
+++ b/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs
@@ -1,5 +1,6 @@
using System;
using System.Globalization;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Enums;
@@ -49,17 +50,25 @@ public class StudiosValidator
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
var names = _itemRepo.GetStudioNames();
+ var existingStudioIds = _libraryManager.GetItemIds(new InternalItemsQuery
+ {
+ IncludeItemTypes = [BaseItemKind.Studio]
+ }).ToHashSet();
var numComplete = 0;
var count = names.Count;
+ var refreshed = 0;
foreach (var name in names)
{
try
{
var item = _libraryManager.GetStudio(name);
-
- await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ if (!existingStudioIds.Contains(item.Id))
+ {
+ await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ refreshed++;
+ }
}
catch (OperationCanceledException)
{
@@ -79,6 +88,8 @@ public class StudiosValidator
progress.Report(percent);
}
+ _logger.LogInformation("Refreshed metadata for {RefreshedCount} new studios out of {TotalCount} total", refreshed, count);
+
var deadEntities = _libraryManager.GetItemList(new InternalItemsQuery
{
IncludeItemTypes = [BaseItemKind.Studio],