Fix redist/tool/server exports

Fixes various issues that may prevent redistributables, tools, or servers from being exported properly.
This commit is contained in:
Pat Hartl 2026-02-28 17:51:30 -06:00
parent 3b3da2980c
commit b8e9a8c8cd
4 changed files with 38 additions and 2 deletions

View file

@ -500,6 +500,8 @@ public class ExportContext(
manifest.Archives.Add(await ExportRecordAsync(queueItem, Archives));
else if (queueItem.Type == ImportExportRecordType.Script)
manifest.Scripts.Add(await ExportRecordAsync(queueItem, Scripts));
else if (queueItem.Type == ImportExportRecordType.Action)
manifest.Actions.Add(await ExportRecordAsync(queueItem, Actions));
}
return manifest;

View file

@ -20,6 +20,14 @@ public class RedistributableExporter(RedistributableService redistributableServi
public override async Task<Redistributable> ExportAsync(Guid id)
{
return await redistributableService.GetAsync<Redistributable>(id);
var redistributable = await redistributableService.GetAsync<Redistributable>(id);
if (redistributable.Archives is null)
redistributable.Archives = new List<Archive>();
if (redistributable.Scripts is null)
redistributable.Scripts = new List<Script>();
return redistributable;
}
}

View file

@ -1,6 +1,8 @@
using AutoMapper;
using LANCommander.SDK.Models.Manifest;
using LANCommander.Server.ImportExport.Models;
using LANCommander.Server.Services;
using Action = LANCommander.SDK.Models.Manifest.Action;
namespace LANCommander.Server.ImportExport.Exporters;
@ -59,6 +61,18 @@ public class ServerExporter(ServerService serverService) : BaseExporter<SDK.Mode
// File could not be added to archive
}
}
if (entity.Scripts is null)
entity.Scripts = new List<Script>();
if (entity.Actions is null)
entity.Actions = new List<Action>();
if (entity.HttpPaths is null)
entity.HttpPaths = new List<ServerHttpPath>();
if (entity.ServerConsoles is null)
entity.ServerConsoles = new List<ServerConsole>();
return entity;
}

View file

@ -2,6 +2,7 @@ using AutoMapper;
using LANCommander.SDK.Models.Manifest;
using LANCommander.Server.ImportExport.Models;
using LANCommander.Server.Services;
using Action = LANCommander.SDK.Models.Manifest.Action;
namespace LANCommander.Server.ImportExport.Exporters;
@ -20,6 +21,17 @@ public class ToolExporter(ToolService toolService) : BaseExporter<Tool, Data.Mod
public override async Task<Tool> ExportAsync(Guid id)
{
return await toolService.GetAsync<Tool>(id);
var tool = await toolService.GetAsync<Tool>(id);
if (tool.Archives is null)
tool.Archives = new List<Archive>();
if (tool.Scripts is null)
tool.Scripts = new List<Script>();
if (tool.Actions is null)
tool.Actions = new List<Action>();
return tool;
}
}