move a computation out of transaction and skip season updates if name matches

This commit is contained in:
cvium 2023-08-23 12:15:21 +02:00
parent 7e4e715a90
commit 9a246166b0
2 changed files with 10 additions and 2 deletions

View File

@ -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();

View File

@ -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);
}
}