From 9a246166b0bddaeacc98c16072a7a714322504f0 Mon Sep 17 00:00:00 2001 From: cvium Date: Wed, 23 Aug 2023 12:15:21 +0200 Subject: [PATCH] move a computation out of transaction and skip season updates if name matches --- Emby.Server.Implementations/Data/SqliteItemRepository.cs | 3 ++- MediaBrowser.Providers/TV/SeriesMetadataService.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index ca121f8a2..40657a0a5 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -564,11 +564,12 @@ namespace Emby.Server.Implementations.Data CheckDisposed(); + var images = SerializeImages(item.ImageInfos); using var connection = GetConnection(); using var transaction = connection.BeginTransaction(); using var saveImagesStatement = PrepareStatement(connection, "Update TypedBaseItems set Images=@Images where guid=@Id"); saveImagesStatement.TryBind("@Id", item.Id); - saveImagesStatement.TryBind("@Images", SerializeImages(item.ImageInfos)); + saveImagesStatement.TryBind("@Images", images); saveImagesStatement.ExecuteNonQuery(); transaction.Commit(); diff --git a/MediaBrowser.Providers/TV/SeriesMetadataService.cs b/MediaBrowser.Providers/TV/SeriesMetadataService.cs index 9016e5de0..a4e2a3333 100644 --- a/MediaBrowser.Providers/TV/SeriesMetadataService.cs +++ b/MediaBrowser.Providers/TV/SeriesMetadataService.cs @@ -1,5 +1,6 @@ #pragma warning disable CS1591 +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -227,7 +228,13 @@ namespace MediaBrowser.Providers.TV } else { - existingSeason.Name = GetValidSeasonNameForSeries(series, seasonName, seasonNumber); + var name = GetValidSeasonNameForSeries(series, seasonName, seasonNumber); + if (string.Equals(existingSeason.Name, name, StringComparison.Ordinal)) + { + continue; + } + + existingSeason.Name = name; await existingSeason.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false); } }