Use md5 Guid for legacy compat

This commit is contained in:
crobibero 2020-12-04 16:27:31 -07:00
parent 3db6ae91f6
commit 76250a8895
2 changed files with 11 additions and 8 deletions

View File

@ -6,6 +6,7 @@ using System.Linq;
using Jellyfin.Api.Constants; using Jellyfin.Api.Constants;
using Jellyfin.Data.Entities; using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@ -47,7 +48,11 @@ namespace Jellyfin.Api.Controllers
[FromQuery, Required] Guid userId, [FromQuery, Required] Guid userId,
[FromQuery, Required] string client) [FromQuery, Required] string client)
{ {
_ = Guid.TryParse(displayPreferencesId, out var itemId); if (!Guid.TryParse(displayPreferencesId, out var itemId))
{
itemId = displayPreferencesId.GetMD5();
}
var displayPreferences = _displayPreferencesManager.GetDisplayPreferences(userId, itemId, client); var displayPreferences = _displayPreferencesManager.GetDisplayPreferences(userId, itemId, client);
var itemPreferences = _displayPreferencesManager.GetItemDisplayPreferences(displayPreferences.UserId, itemId, displayPreferences.Client); var itemPreferences = _displayPreferencesManager.GetItemDisplayPreferences(displayPreferences.UserId, itemId, displayPreferences.Client);
itemPreferences.ItemId = itemId; itemPreferences.ItemId = itemId;
@ -127,7 +132,11 @@ namespace Jellyfin.Api.Controllers
HomeSectionType.LatestMedia, HomeSectionType.None, HomeSectionType.LatestMedia, HomeSectionType.None,
}; };
_ = Guid.TryParse(displayPreferencesId, out var itemId); if (!Guid.TryParse(displayPreferencesId, out var itemId))
{
itemId = displayPreferencesId.GetMD5();
}
var existingDisplayPreferences = _displayPreferencesManager.GetDisplayPreferences(userId, itemId, client); var existingDisplayPreferences = _displayPreferencesManager.GetDisplayPreferences(userId, itemId, client);
existingDisplayPreferences.IndexBy = Enum.TryParse<IndexingKind>(displayPreferences.IndexBy, true, out var indexBy) ? indexBy : (IndexingKind?)null; existingDisplayPreferences.IndexBy = Enum.TryParse<IndexingKind>(displayPreferences.IndexBy, true, out var indexBy) ? indexBy : (IndexingKind?)null;
existingDisplayPreferences.ShowBackdrop = displayPreferences.ShowBackdrop; existingDisplayPreferences.ShowBackdrop = displayPreferences.ShowBackdrop;

View File

@ -81,7 +81,6 @@ namespace Jellyfin.Server.Migrations.Routines
{ "unstable", ChromecastVersion.Unstable } { "unstable", ChromecastVersion.Unstable }
}; };
var defaultDisplayPrefsId = "usersettings".GetMD5();
var dbFilePath = Path.Combine(_paths.DataPath, DbFilename); var dbFilePath = Path.Combine(_paths.DataPath, DbFilename);
using (var connection = SQLite3.Open(dbFilePath, ConnectionFlags.ReadOnly, null)) using (var connection = SQLite3.Open(dbFilePath, ConnectionFlags.ReadOnly, null))
{ {
@ -97,11 +96,6 @@ namespace Jellyfin.Server.Migrations.Routines
} }
var itemId = new Guid(result[1].ToBlob()); var itemId = new Guid(result[1].ToBlob());
if (itemId == defaultDisplayPrefsId)
{
itemId = Guid.Empty;
}
var dtoUserId = new Guid(result[1].ToBlob()); var dtoUserId = new Guid(result[1].ToBlob());
var existingUser = _userManager.GetUserById(dtoUserId); var existingUser = _userManager.GetUserById(dtoUserId);
if (existingUser == null) if (existingUser == null)