Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8074163cff | ||
|
|
771dbe72e9 |
2 changed files with 17 additions and 28 deletions
|
|
@ -82,8 +82,8 @@ else
|
|||
[Parameter] public LibraryItem Model { get; set; }
|
||||
[Parameter] public RenderFragment MenuExtra { get; set; }
|
||||
|
||||
Data.Models.Game Game { get; set; }
|
||||
IEnumerable<SDK.Models.Action> GameActions { get; set; }
|
||||
Data.Models.Game Game { get; set; } = new Game();
|
||||
IEnumerable<SDK.Models.Action> GameActions { get; set; } = new List<SDK.Models.Action>();
|
||||
|
||||
Settings Settings;
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ else
|
|||
{
|
||||
var manifest = ManifestHelper.Read(Game.InstallDirectory, Game.Id);
|
||||
|
||||
if (manifest != null)
|
||||
if (manifest != null && manifest.Actions != null)
|
||||
GameActions = manifest.Actions.Where(a => !a.IsPrimaryAction).ToList();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using SharpCompress.Archives;
|
|||
using SharpCompress.Archives.Zip;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Readers;
|
||||
using SharpCompress.Writers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
@ -239,10 +240,12 @@ namespace LANCommander.SDK.Services
|
|||
|
||||
if (manifest.SavePaths != null && manifest.SavePaths.Count() > 0)
|
||||
{
|
||||
using (var archive = ZipArchive.Create())
|
||||
using (var ms = new MemoryStream())
|
||||
using (var writer = WriterFactory.Open(ms, ArchiveType.Zip, new WriterOptions(CompressionType.Deflate)
|
||||
{
|
||||
ArchiveEncoding = new ArchiveEncoding() { Default = Encoding.UTF8 }
|
||||
}))
|
||||
{
|
||||
archive.DeflateCompressionLevel = SharpCompress.Compressors.Deflate.CompressionLevel.BestCompression;
|
||||
|
||||
#region Add files from defined paths
|
||||
foreach (var savePath in manifest.SavePaths.Where(sp => sp.Type == Enums.SavePathType.File))
|
||||
{
|
||||
|
|
@ -253,11 +256,9 @@ namespace LANCommander.SDK.Services
|
|||
var localPath = GetLocalPath(entry.ActualPath, installDirectory);
|
||||
|
||||
if (Directory.Exists(localPath))
|
||||
AddDirectoryToZip(archive, entry.ArchivePath, localPath, savePath.Id);
|
||||
AddDirectoryToZip(writer, entry.ArchivePath, localPath, savePath.Id);
|
||||
else if (File.Exists(localPath))
|
||||
{
|
||||
archive.AddEntry($"Files/{savePath.Id}/{entry.ArchivePath}", localPath);
|
||||
}
|
||||
writer.Write($"Files/{savePath.Id}/{entry.ArchivePath}", localPath);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -296,27 +297,15 @@ namespace LANCommander.SDK.Services
|
|||
File.Delete(tempRegFile);
|
||||
}
|
||||
|
||||
archive.AddEntry("_registry.reg", new MemoryStream(Encoding.UTF8.GetBytes(exportFile.ToString())), true);
|
||||
writer.Write("_registry.reg", new MemoryStream(Encoding.UTF8.GetBytes(exportFile.ToString())));
|
||||
}
|
||||
#endregion
|
||||
|
||||
var tempManifest = Path.GetTempFileName();
|
||||
writer.Write(ManifestHelper.ManifestFilename, new MemoryStream(Encoding.UTF8.GetBytes(ManifestHelper.Serialize(manifest))));
|
||||
|
||||
File.WriteAllText(tempManifest, ManifestHelper.Serialize(manifest));
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
archive.AddEntry(ManifestHelper.ManifestFilename, tempManifest);
|
||||
|
||||
using (var op = Logger.BeginOperation("Pack and upload save"))
|
||||
{
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
archive.SaveTo(ms);
|
||||
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
var save = Upload(manifest.Id, ms.ToArray());
|
||||
}
|
||||
}
|
||||
var save = Upload(manifest.Id, ms.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -414,13 +403,13 @@ namespace LANCommander.SDK.Services
|
|||
return archivePath;
|
||||
}
|
||||
|
||||
private void AddDirectoryToZip(ZipArchive zipArchive, string archivePath, string localPath, Guid pathId)
|
||||
private void AddDirectoryToZip(IWriter writer, string archivePath, string localPath, Guid pathId)
|
||||
{
|
||||
foreach (var file in Directory.GetFiles(localPath, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
var fileArchivePath = file.Substring(localPath.Length).Replace(Path.DirectorySeparatorChar, '/').Trim('/');
|
||||
|
||||
zipArchive.AddEntry($"Files/{pathId}/{archivePath}/{fileArchivePath}", file);
|
||||
writer.Write($"Files/{pathId}/{archivePath}/{fileArchivePath}", file);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue