diff --git a/LANCommander.Server.ImportExport/Exporters/GameExporter.cs b/LANCommander.Server.ImportExport/Exporters/GameExporter.cs index 1414e0c2..c2b5b5f5 100644 --- a/LANCommander.Server.ImportExport/Exporters/GameExporter.cs +++ b/LANCommander.Server.ImportExport/Exporters/GameExporter.cs @@ -21,9 +21,8 @@ public class GameExporter( public override async Task ExportAsync(Guid id) { - // Retrieve the game again, but only get the minimal amount of data required - var manifest = await gameService.GetAsync(id); - + var manifest = await gameService.GetManifestAsync(id); + manifest.Actions ??= new List(); manifest.Archives ??= new List(); manifest.Collections ??= new List(); @@ -36,6 +35,7 @@ public class GameExporter( manifest.Platforms ??= new List(); manifest.PlaySessions ??= new List(); manifest.Publishers ??= new List(); + manifest.Redistributables ??= new List(); manifest.Saves ??= new List(); manifest.SavePaths ??= new List(); manifest.Scripts ??= new List(); diff --git a/LANCommander.Server.ImportExport/Importers/ActionImporter.cs b/LANCommander.Server.ImportExport/Importers/ActionImporter.cs index 742b2ceb..70ea4be0 100644 --- a/LANCommander.Server.ImportExport/Importers/ActionImporter.cs +++ b/LANCommander.Server.ImportExport/Importers/ActionImporter.cs @@ -37,10 +37,12 @@ public class ActionImporter( var action = new Data.Models.Action { Name = record.Name, + Arguments = record.Arguments, Path = record.Path, WorkingDirectory = record.WorkingDirectory, PrimaryAction = record.IsPrimaryAction, SortOrder = record.SortOrder, + OptionOverrides = record.OptionOverrides, CreatedOn = record.CreatedOn, UpdatedOn = record.UpdatedOn, }; @@ -83,10 +85,12 @@ public class ActionImporter( try { + existing.Arguments = record.Arguments; existing.Path = record.Path; existing.WorkingDirectory = record.WorkingDirectory; existing.PrimaryAction = record.IsPrimaryAction; existing.SortOrder = record.SortOrder; + existing.OptionOverrides = record.OptionOverrides; existing.CreatedOn = record.CreatedOn; existing.UpdatedOn = record.UpdatedOn; diff --git a/LANCommander.Server.ImportExport/Importers/GameImporter.cs b/LANCommander.Server.ImportExport/Importers/GameImporter.cs index a2a0a6c5..25390d18 100644 --- a/LANCommander.Server.ImportExport/Importers/GameImporter.cs +++ b/LANCommander.Server.ImportExport/Importers/GameImporter.cs @@ -9,6 +9,7 @@ namespace LANCommander.Server.ImportExport.Importers; public class GameImporter( ILogger logger, GameService gameService, + RedistributableService redistributableService, UserService userService) : BaseImporter { public override string GetKey(Game record) @@ -166,6 +167,29 @@ public class GameImporter( manifest.Tags, r => t => t.Name == r.Name); + if (manifest.Redistributables != null && manifest.Redistributables.Any()) + { + await gameService.SyncRelatedCollectionAsync( + game, + g => g.Redistributables, + manifest.Redistributables, + r => rd => rd.Id == r.Id || rd.Name == r.Name); + + foreach (var redistributable in manifest.Redistributables) + { + if (redistributable.Options != null && redistributable.Options.Any()) + { + var existing = await redistributableService.FirstOrDefaultAsync(r => r.Id == redistributable.Id || r.Name == redistributable.Name); + + if (existing != null) + { + var optionsJson = System.Text.Json.JsonSerializer.Serialize(redistributable.Options); + await gameService.SetRedistributableOptionsAsync(game.Id, existing.Id, optionsJson); + } + } + } + } + if (!string.IsNullOrWhiteSpace(manifest.BaseGame) || manifest.BaseGameId != Guid.Empty) { Data.Models.Game? baseGame = null; diff --git a/LANCommander.Server.ImportExport/Importers/RedistributableImporter.cs b/LANCommander.Server.ImportExport/Importers/RedistributableImporter.cs index d5e0e922..c022f042 100644 --- a/LANCommander.Server.ImportExport/Importers/RedistributableImporter.cs +++ b/LANCommander.Server.ImportExport/Importers/RedistributableImporter.cs @@ -52,6 +52,7 @@ public class RedistributableImporter( existing.Name = record.Name; existing.Description = record.Description; existing.Notes = record.Notes; + existing.OptionSchema = record.OptionSchema; existing.CreatedOn = record.CreatedOn; existing.CreatedBy = await userService.GetAsync(record.CreatedBy); existing.UpdatedOn = record.UpdatedOn;