diff --git a/LANCommander.Server.ImportExport/ImportContext.cs b/LANCommander.Server.ImportExport/ImportContext.cs index c666d197..f1de1fcc 100644 --- a/LANCommander.Server.ImportExport/ImportContext.cs +++ b/LANCommander.Server.ImportExport/ImportContext.cs @@ -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}", }); } diff --git a/LANCommander.Server.ImportExport/Importers/ArchiveImporter.cs b/LANCommander.Server.ImportExport/Importers/ArchiveImporter.cs index 46056bd1..c960c6f4 100644 --- a/LANCommander.Server.ImportExport/Importers/ArchiveImporter.cs +++ b/LANCommander.Server.ImportExport/Importers/ArchiveImporter.cs @@ -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; diff --git a/LANCommander.Server.ImportExport/Importers/ScriptImporter.cs b/LANCommander.Server.ImportExport/Importers/ScriptImporter.cs index c7f30d0e..64552626 100644 --- a/LANCommander.Server.ImportExport/Importers/ScriptImporter.cs +++ b/LANCommander.Server.ImportExport/Importers/ScriptImporter.cs @@ -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) diff --git a/LANCommander.Server.ImportExport/Models/ImportAssetText.cs b/LANCommander.Server.ImportExport/Models/ImportAssetText.cs index b6db43a0..8fa8826d 100644 --- a/LANCommander.Server.ImportExport/Models/ImportAssetText.cs +++ b/LANCommander.Server.ImportExport/Models/ImportAssetText.cs @@ -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; } } \ No newline at end of file diff --git a/LANCommander.Server.Services/ArchiveService.cs b/LANCommander.Server.Services/ArchiveService.cs index 700d07af..0ccabba0 100644 --- a/LANCommander.Server.Services/ArchiveService.cs +++ b/LANCommander.Server.Services/ArchiveService.cs @@ -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 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 GetArchiveFileLocationAsync(string objectKey)