Fix import issues with scripts, archives, and legacy manifests

- Scripts now import properly
- Archives now import properly when using non-absolute storage location paths
- Support legacy LCX files that have manifests with the name _manifest.yml
This commit is contained in:
Pat Hartl 2026-01-24 22:32:12 -06:00
parent 6809e3b0da
commit 406a92b104
5 changed files with 14 additions and 5 deletions

View file

@ -126,6 +126,10 @@ public class ImportContext : IDisposable
Archive = ZipArchive.Open(archivePath);
var manifestEntry = Archive.Entries.FirstOrDefault(e => e.Key == ManifestHelper.ManifestFilename);
// Legacy purposes
if (manifestEntry == null)
manifestEntry = Archive.Entries.FirstOrDefault(e => e.Key == "_manifest.yml");
if (manifestEntry == null)
throw new InvalidOperationException("Invalid import file, cannot load manifest");
@ -163,11 +167,11 @@ public class ImportContext : IDisposable
if (gameManifest.Scripts != null)
foreach (var script in gameManifest.Scripts)
{
_scripts.AddAsset(new ImportAssetText
_scripts.AddAsset(new ImportAssetArchiveEntry
{
Name = script.Name,
RecordId = script.Id,
Contents = script.Contents,
Path = $"Scripts/{script.Id}",
});
}

View file

@ -164,7 +164,7 @@ public class ArchiveImporter(
}
catch (Exception ex)
{
logger.LogError(ex, "Could not injest archive entry");
logger.LogError(ex, "Could not ingest archive entry");
}
return false;

View file

@ -55,12 +55,14 @@ public class ScriptImporter(
{
var newScript = new Data.Models.Script
{
Id = record.Id,
CreatedOn = record.CreatedOn,
UpdatedOn = record.UpdatedOn,
Name = record.Name,
Description = record.Description,
RequiresAdmin = record.RequiresAdmin,
Type = record.Type,
Contents = string.Empty,
};
if (ImportContext.Manifest is Game game)

View file

@ -5,4 +5,5 @@ public class ImportAssetText : IImportAsset
public Guid RecordId { get; set; }
public string Name { get; set; }
public string Contents { get; set; }
public string Path { get; set; }
}

View file

@ -36,7 +36,9 @@ namespace LANCommander.Server.Services
public string GetArchiveFileLocation(Archive archive, StorageLocation storageLocation)
{
return Path.Combine(storageLocation.Path, archive.ObjectKey);
return Path.IsPathRooted(storageLocation.Path)
? Path.Combine(storageLocation.Path, archive.ObjectKey)
: AppPaths.GetConfigPath(storageLocation.Path, archive.ObjectKey);
}
public async Task<string> GetArchiveFileLocationAsync(Archive archive)
@ -54,7 +56,7 @@ namespace LANCommander.Server.Services
return Path.IsPathRooted(storageLocationPath) ?
Path.Combine(storageLocationPath, archive.ObjectKey) :
Path.Combine(AppPaths.GetConfigDirectory(), storageLocationPath, archive.ObjectKey);
AppPaths.GetConfigPath(storageLocationPath, archive.ObjectKey);
}
public async Task<string> GetArchiveFileLocationAsync(string objectKey)