Fix issue where updating to v0.6.0 would duplicate library items and break some games

Playnite doesn't allow the editing of IDs. This fix removes the original game entry and adds the migrated one as a new game. Install status and directory are maintained.
This commit is contained in:
Pat Hartl 2024-02-22 17:19:45 -06:00
parent da3bdb4f1f
commit 3d37da29fe
2 changed files with 4 additions and 19 deletions

View file

@ -109,24 +109,6 @@ namespace LANCommander.PlaynitePlugin
game.Name += " - Update Available";
}
if (!game.IsInstalled && String.IsNullOrWhiteSpace(game.InstallDirectory))
{
try
{
// Check for existing manifest
var possibleInstallDirectory = Path.Combine(Plugin.Settings.InstallDirectory, game.Name.SanitizeFilename());
var existingManifest = ManifestHelper.Read(possibleInstallDirectory, game.Id);
if (existingManifest != null)
{
game.IsInstalled = true;
game.InstallDirectory = possibleInstallDirectory;
}
}
catch { }
}
#region Play Sessions
if (playSessions.Count() > 0)
{

View file

@ -676,9 +676,12 @@ namespace LANCommander.PlaynitePlugin
{
try
{
var originalId = game.Id;
game.Id = Guid.Parse(game.GameId);
PlayniteApi.Database.Games.Update(game);
PlayniteApi.Database.Games.Remove(originalId);
PlayniteApi.Database.Games.Add(game);
}
catch (Exception ex)
{