The Free Software Media System - Server Backend & API
fix ExternalId being lost
Luke Pulverenti1adfbfadf16f
diff --git a/Emby.Server.Core/Data/DataExtensions.cs b/Emby.Server.Core/Data/DataExtensions.csindex 631c1c5005..20766619ee 100644--- a/Emby.Server.Core/Data/DataExtensions.cs+++ b/Emby.Server.Core/Data/DataExtensions.cs@@ -25,6 +25,11 @@ namespace Emby.Server.Core.Datareturn (IDataParameter)cmd.Parameters[index];}+ public static IDataParameter GetParameter(this IDbCommand cmd, string name)+ {+ return (IDataParameter)cmd.Parameters[name];+ }+public static IDataParameter Add(this IDataParameterCollection paramCollection, IDbCommand cmd, string name, DbType type){var param = cmd.CreateParameter();diff --git a/Emby.Server.Core/Data/SqliteItemRepository.cs b/Emby.Server.Core/Data/SqliteItemRepository.csindex c2328641c6..91c46222b8 100644--- a/Emby.Server.Core/Data/SqliteItemRepository.cs+++ b/Emby.Server.Core/Data/SqliteItemRepository.cs@@ -810,7 +810,15 @@ namespace Emby.Server.Core.Data_saveItemCommand.GetParameter(index++).Value = item.ParentId;}- _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Genres.ToArray());+ if (item.Genres.Count > 0)+ {+ _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Genres.ToArray());+ }+ else+ {+ _saveItemCommand.GetParameter(index++).Value = null;+ }+_saveItemCommand.GetParameter(index++).Value = item.GetInheritedParentalRatingValue() ?? 0;_saveItemCommand.GetParameter(index++).Value = LatestSchemaVersion;@@ -852,8 +860,23 @@ namespace Emby.Server.Core.Data}_saveItemCommand.GetParameter(index++).Value = item.IsInMixedFolder;- _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.LockedFields.Select(i => i.ToString()).ToArray());- _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Studios.ToArray());+ if (item.LockedFields.Count > 0)+ {+ _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.LockedFields.Select(i => i.ToString()).ToArray());+ }+ else+ {+ _saveItemCommand.GetParameter(index++).Value = null;+ }++ if (item.Studios.Count > 0)+ {+ _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Studios.ToArray());+ }+ else+ {+ _saveItemCommand.GetParameter(index++).Value = null;+ }if (item.Audio.HasValue){@@ -1043,31 +1066,27 @@ namespace Emby.Server.Core.Data_saveItemCommand.GetParameter(index++).Value = item.TotalBitrate;_saveItemCommand.GetParameter(index++).Value = item.ExtraType;+ string artists = null;var hasArtists = item as IHasArtist;if (hasArtists != null){if (hasArtists.Artists.Count > 0){- _saveItemCommand.GetParameter(index++).Value = string.Join("|", hasArtists.Artists.ToArray());- }- else- {- _saveItemCommand.GetParameter(index++).Value = null;+ artists = string.Join("|", hasArtists.Artists.ToArray());}}+ _saveItemCommand.GetParameter(index++).Value = artists;+ string albumArtists = null;var hasAlbumArtists = item as IHasAlbumArtist;if (hasAlbumArtists != null){if (hasAlbumArtists.AlbumArtists.Count > 0){- _saveItemCommand.GetParameter(index++).Value = string.Join("|", hasAlbumArtists.AlbumArtists.ToArray());- }- else- {- _saveItemCommand.GetParameter(index++).Value = null;+ albumArtists = string.Join("|", hasAlbumArtists.AlbumArtists.ToArray());}}+ _saveItemCommand.GetParameter(index++).Value = albumArtists;_saveItemCommand.GetParameter(index++).Value = item.ExternalId;diff --git a/Emby.Server.Core/Notifications/SqliteNotificationsRepository.cs b/Emby.Server.Core/Notifications/SqliteNotificationsRepository.csindex dee0d4cfdd..cd4ac28dcd 100644--- a/Emby.Server.Core/Notifications/SqliteNotificationsRepository.cs+++ b/Emby.Server.Core/Notifications/SqliteNotificationsRepository.cs@@ -260,16 +260,16 @@ namespace Emby.Server.Core.Notifications{transaction = connection.BeginTransaction();- replaceNotificationCommand.GetParameter(0).Value = new Guid(notification.Id);- replaceNotificationCommand.GetParameter(1).Value = new Guid(notification.UserId);- replaceNotificationCommand.GetParameter(2).Value = notification.Date.ToUniversalTime();- replaceNotificationCommand.GetParameter(3).Value = notification.Name;- replaceNotificationCommand.GetParameter(4).Value = notification.Description;- replaceNotificationCommand.GetParameter(5).Value = notification.Url;- replaceNotificationCommand.GetParameter(6).Value = notification.Level.ToString();- replaceNotificationCommand.GetParameter(7).Value = notification.IsRead;- replaceNotificationCommand.GetParameter(8).Value = string.Empty;- replaceNotificationCommand.GetParameter(9).Value = string.Empty;+ replaceNotificationCommand.GetParameter("@Id").Value = new Guid(notification.Id);+ replaceNotificationCommand.GetParameter("@UserId").Value = new Guid(notification.UserId);+ replaceNotificationCommand.GetParameter("@Date").Value = notification.Date.ToUniversalTime();+ replaceNotificationCommand.GetParameter("@Name").Value = notification.Name;+ replaceNotificationCommand.GetParameter("@Description").Value = notification.Description;+ replaceNotificationCommand.GetParameter("@Url").Value = notification.Url;+ replaceNotificationCommand.GetParameter("@Level").Value = notification.Level.ToString();+ replaceNotificationCommand.GetParameter("@IsRead").Value = notification.IsRead;+ replaceNotificationCommand.GetParameter("@Category").Value = string.Empty;+ replaceNotificationCommand.GetParameter("@RelatedId").Value = string.Empty;replaceNotificationCommand.Transaction = transaction;diff --git a/Emby.Server.Core/Security/AuthenticationRepository.cs b/Emby.Server.Core/Security/AuthenticationRepository.csindex eaf91c710e..548585375d 100644--- a/Emby.Server.Core/Security/AuthenticationRepository.cs+++ b/Emby.Server.Core/Security/AuthenticationRepository.cs@@ -80,18 +80,16 @@ namespace Emby.Server.Core.Security{transaction = connection.BeginTransaction();- var index = 0;-- saveInfoCommand.GetParameter(index++).Value = new Guid(info.Id);- saveInfoCommand.GetParameter(index++).Value = info.AccessToken;- saveInfoCommand.GetParameter(index++).Value = info.DeviceId;- saveInfoCommand.GetParameter(index++).Value = info.AppName;- saveInfoCommand.GetParameter(index++).Value = info.AppVersion;- saveInfoCommand.GetParameter(index++).Value = info.DeviceName;- saveInfoCommand.GetParameter(index++).Value = info.UserId;- saveInfoCommand.GetParameter(index++).Value = info.IsActive;- saveInfoCommand.GetParameter(index++).Value = info.DateCreated;- saveInfoCommand.GetParameter(index++).Value = info.DateRevoked;+ saveInfoCommand.GetParameter("@Id").Value = new Guid(info.Id);+ saveInfoCommand.GetParameter("@AccessToken").Value = info.AccessToken;+ saveInfoCommand.GetParameter("@DeviceId").Value = info.DeviceId;+ saveInfoCommand.GetParameter("@AppName").Value = info.AppName;+ saveInfoCommand.GetParameter("@AppVersion").Value = info.AppVersion;+ saveInfoCommand.GetParameter("@DeviceName").Value = info.DeviceName;+ saveInfoCommand.GetParameter("@UserId").Value = info.UserId;+ saveInfoCommand.GetParameter("@IsActive").Value = info.IsActive;+ saveInfoCommand.GetParameter("@DateCreated").Value = info.DateCreated;+ saveInfoCommand.GetParameter("@DateRevoked").Value = info.DateRevoked;saveInfoCommand.Transaction = transaction;