From 99c4ed73fcbd7308dc7edb2f958bf479b1ddea57 Mon Sep 17 00:00:00 2001 From: Brett Hewitson Date: Wed, 18 May 2022 22:12:15 +1000 Subject: [PATCH] World Save Zipping - have changed the way the zip file is created. All files are now added to the zip in one pass, rather than as separate files. --- src/ARKServerManager/Lib/ServerApp.cs | 19 +++- src/ARKServerManager/VersionFeed.xml | 25 ++++- src/ARKServerManager/VersionFeedBeta.xml | 103 +-------------------- src/ConanServerManager/Lib/ServerApp.cs | 13 ++- src/ConanServerManager/VersionFeed.xml | 25 ++++- src/ConanServerManager/VersionFeedBeta.xml | 83 ++--------------- src/ServerManager.Common/Utils/ZipUtils.cs | 37 ++++++++ 7 files changed, 121 insertions(+), 184 deletions(-) diff --git a/src/ARKServerManager/Lib/ServerApp.cs b/src/ARKServerManager/Lib/ServerApp.cs index 24790303..e0c15723 100644 --- a/src/ARKServerManager/Lib/ServerApp.cs +++ b/src/ARKServerManager/Lib/ServerApp.cs @@ -2069,14 +2069,17 @@ namespace ServerManagerTool.Lib var saveFolderInfo = new DirectoryInfo(saveFolder); // backup the world save file - ZipUtils.ZipFile(backupFile, "", worldFile, comment.ToString()); + var files = new Dictionary> + { + { "", new List { worldFile } } + }; // backup the player files var playerFileFilter = $"*{Config.Default.PlayerFileExtension}"; var playerFiles = saveFolderInfo.GetFiles(playerFileFilter, SearchOption.TopDirectoryOnly); foreach (var file in playerFiles) { - ZipUtils.ZipFile(backupFile, "", file.FullName); + files[""].Add(file.FullName); } // backup the tribe files @@ -2084,7 +2087,7 @@ namespace ServerManagerTool.Lib var tribeFiles = saveFolderInfo.GetFiles(tribeFileFilter, SearchOption.TopDirectoryOnly); foreach (var file in tribeFiles) { - ZipUtils.ZipFile(backupFile, "", file.FullName); + files[""].Add(file.FullName); } // backup the tribute tribe files @@ -2092,7 +2095,7 @@ namespace ServerManagerTool.Lib var tributeTribeFiles = saveFolderInfo.GetFiles(tributeTribeFileFilter, SearchOption.TopDirectoryOnly); foreach (var file in tributeTribeFiles) { - ZipUtils.ZipFile(backupFile, "", file.FullName); + files[""].Add(file.FullName); } if (Config.Default.AutoBackup_IncludeSaveGamesFolder) @@ -2107,11 +2110,17 @@ namespace ServerManagerTool.Lib var saveGamesFiles = saveGamesFolderInfo.GetFiles(saveGamesFileFilter, SearchOption.AllDirectories); foreach (var file in saveGamesFiles) { - ZipUtils.ZipFile(backupFile, file.DirectoryName.Replace(saveGamesFolder, Config.Default.SaveGamesRelativePath), file.FullName); + var key = file.DirectoryName.Replace(saveGamesFolder, Config.Default.SaveGamesRelativePath); + if (files.ContainsKey(key)) + files[key].Add(file.FullName); + else + files.Add(key, new List { file.FullName }); } } } + ZipUtils.ZipFiles(backupFile, files, comment.ToString()); + LogProfileMessage($"Backed up world files - {saveFolder}"); LogProfileMessage($"Backup file created - {backupFile}"); diff --git a/src/ARKServerManager/VersionFeed.xml b/src/ARKServerManager/VersionFeed.xml index 74eb2309..656f0905 100644 --- a/src/ARKServerManager/VersionFeed.xml +++ b/src/ARKServerManager/VersionFeed.xml @@ -5,7 +5,30 @@ Ark Server Manager Version Feed This is the Ark Server Manager release version feed. - 2022-05-15T00:00:00Z + 2022-05-18T00:00:00Z + + + urn:uuid:D0681B47-5715-473E-99D3-63F475A997C4 + 1.1.429 (1.1.429.1) + 1.1.429.1 + + 2022-05-18T00:00:00Z + +
+

+ CHANGE +
+

    +
  • World Save Zipping - have changed the way the zip file is created. All files are now added to the zip in one pass, rather than as separate files.
  • +
+

+
+
+ + bletch + bletch1971@hotmail.com + +
urn:uuid:2E2A14AE-EE5B-4384-8143-BF5D1C8A487D diff --git a/src/ARKServerManager/VersionFeedBeta.xml b/src/ARKServerManager/VersionFeedBeta.xml index 031eb234..e82abdc6 100644 --- a/src/ARKServerManager/VersionFeedBeta.xml +++ b/src/ARKServerManager/VersionFeedBeta.xml @@ -8,111 +8,18 @@ 2022-05-15T00:00:00Z - urn:uuid:2E2A14AE-EE5B-4384-8143-BF5D1C8A487D - 1.1.428 (1.1.428.5) - 1.1.428.5 + urn:uuid:D0681B47-5715-473E-99D3-63F475A997C4 + 1.1.429 (1.1.429.1) + 1.1.429.1 - 2022-05-15T00:00:00Z + 2022-05-18T00:00:00Z

CHANGE

    -
  • de-DE Translation file updated.
  • -
-

-
-
- - bletch - bletch1971@hotmail.com - -
- - - urn:uuid:2E2A14AE-EE5B-4384-8143-BF5D1C8A487D - 1.1.428 (1.1.428.4) - 1.1.428.4 - - 2022-05-15T00:00:00Z - -
-

- CHANGE -
-

    -
  • pt-BR Translation file updated.
  • -
  • ru-RU Translation file updated.
  • -
-

-
-
- - bletch - bletch1971@hotmail.com - -
- - - urn:uuid:2E2A14AE-EE5B-4384-8143-BF5D1C8A487D - 1.1.428 (1.1.428.3) - 1.1.428.3 - - 2022-05-15T00:00:00Z - -
-

- CHANGE -
-

    -
  • Player List - adjusted the margin around the border of the players in the player list.
  • -
-

-
-
- - bletch - bletch1971@hotmail.com - -
- - - urn:uuid:2E2A14AE-EE5B-4384-8143-BF5D1C8A487D - 1.1.428 (1.1.428.2) - 1.1.428.2 - - 2022-05-15T00:00:00Z - -
-

- CHANGE -
-

    -
  • Auto Process Task Priorities - Have added task priority droplists to the global settings, allowing the priority for each auto process task to be changed.
  • -
-

-
-
- - bletch - bletch1971@hotmail.com - -
- - - urn:uuid:2E2A14AE-EE5B-4384-8143-BF5D1C8A487D - 1.1.428 (1.1.428.1) - 1.1.428.1 - - 2022-05-15T00:00:00Z - -
-

- BUGFIX -
-

    -
  • Server Shutdown/Restart - rewritten the code that sends the RCON commands to prevent the hangs after the RCON command fails.
  • +
  • World Save Zipping - have changed the way the zip file is created. All files are now added to the zip in one pass, rather than as separate files.

diff --git a/src/ConanServerManager/Lib/ServerApp.cs b/src/ConanServerManager/Lib/ServerApp.cs index 21b4ab81..d2afaab2 100644 --- a/src/ConanServerManager/Lib/ServerApp.cs +++ b/src/ConanServerManager/Lib/ServerApp.cs @@ -1991,7 +1991,10 @@ namespace ServerManagerTool.Lib var saveFolderInfo = new DirectoryInfo(saveFolder); // backup the world save file - ZipUtils.ZipFile(backupFile, "", worldFile, comment.ToString()); + var files = new Dictionary> + { + { "", new List { worldFile } } + }; if (Config.Default.AutoBackup_IncludeSaveGamesFolder) { @@ -2005,11 +2008,17 @@ namespace ServerManagerTool.Lib var saveGamesFiles = saveGamesFolderInfo.GetFiles(saveGamesFileFilter, SearchOption.AllDirectories); foreach (var file in saveGamesFiles) { - ZipUtils.ZipFile(backupFile, file.DirectoryName.Replace(saveGamesFolder, Config.Default.SaveGamesRelativePath), file.FullName); + var key = file.DirectoryName.Replace(saveGamesFolder, Config.Default.SaveGamesRelativePath); + if (files.ContainsKey(key)) + files[key].Add(file.FullName); + else + files.Add(key, new List { file.FullName }); } } } + ZipUtils.ZipFiles(backupFile, files, comment.ToString()); + LogProfileMessage($"Backed up world files - {saveFolder}"); LogProfileMessage($"Backup file created - {backupFile}"); diff --git a/src/ConanServerManager/VersionFeed.xml b/src/ConanServerManager/VersionFeed.xml index 39b2a6c3..d9c7852f 100644 --- a/src/ConanServerManager/VersionFeed.xml +++ b/src/ConanServerManager/VersionFeed.xml @@ -5,7 +5,30 @@ Conan Server Manager Version Feed This is the Conan Server Manager release version feed. - 2022-05-15T00:00:00Z + 2022-05-18T00:00:00Z + + + urn:uuid:D0681B47-5715-473E-99D3-63F475A997C4 + 1.1.73 (1.1.72.1) + 1.1.73.1 + + 2022-05-18T00:00:00Z + +
+

+ CHANGE +
+

    +
  • World Save Zipping - have changed the way the zip file is created. All files are now added to the zip in one pass, rather than as separate files.
  • +
+

+
+
+ + bletch + bletch1971@hotmail.com + +
urn:uuid:E367ACB5-E38A-4B3A-A089-E43D011A97E4 diff --git a/src/ConanServerManager/VersionFeedBeta.xml b/src/ConanServerManager/VersionFeedBeta.xml index 99b93b9d..ecb63080 100644 --- a/src/ConanServerManager/VersionFeedBeta.xml +++ b/src/ConanServerManager/VersionFeedBeta.xml @@ -5,92 +5,21 @@ Conan Server Manager Version Feed This is the Conan Server Manager beta version feed. - 2022-05-15T00:00:00Z + 2022-05-18T00:00:00Z - urn:uuid:E367ACB5-E38A-4B3A-A089-E43D011A97E4 - 1.1.72 (1.1.72.4) - 1.1.72.4 + urn:uuid:D0681B47-5715-473E-99D3-63F475A997C4 + 1.1.73 (1.1.72.1) + 1.1.73.1 - 2022-05-15T00:00:00Z + 2022-05-18T00:00:00Z

CHANGE

    -
  • de-DE Translation file added.
  • -
  • pt-BR Translation file updated.
  • -
  • ru-RU Translation file updated.
  • -
-

-
-
- - bletch - bletch1971@hotmail.com - -
- - - urn:uuid:E367ACB5-E38A-4B3A-A089-E43D011A97E4 - 1.1.72 (1.1.72.3) - 1.1.72.3 - - 2022-05-15T00:00:00Z - -
-

- CHANGE -
-

    -
  • Player List - adjusted the margin around the border of the players in the player list.
  • -
-

-
-
- - bletch - bletch1971@hotmail.com - -
- - - urn:uuid:E367ACB5-E38A-4B3A-A089-E43D011A97E4 - 1.1.72 (1.1.72.2) - 1.1.72.2 - - 2022-05-15T00:00:00Z - -
-

- CHANGE -
-

    -
  • Auto Process Task Priorities - Have added task priority droplists to the global settings, allowing the priority for each auto process task to be changed.
  • -
-

-
-
- - bletch - bletch1971@hotmail.com - -
- - - urn:uuid:E367ACB5-E38A-4B3A-A089-E43D011A97E4 - 1.1.72 (1.1.72.1) - 1.1.72.1 - - 2022-05-15T00:00:00Z - -
-

- BUGFIX -
-

    -
  • Server Shutdown/Restart - have rewritten the code that sends the RCON commands to prevent the hangs after the RCON command fails.
  • +
  • World Save Zipping - have changed the way the zip file is created. All files are now added to the zip in one pass, rather than as separate files.

diff --git a/src/ServerManager.Common/Utils/ZipUtils.cs b/src/ServerManager.Common/Utils/ZipUtils.cs index 73b31b23..7e747ae2 100644 --- a/src/ServerManager.Common/Utils/ZipUtils.cs +++ b/src/ServerManager.Common/Utils/ZipUtils.cs @@ -108,9 +108,13 @@ namespace ServerManagerTool.Common.Utils var selection = new List(); if (recurseFolders) + { selection.AddRange(zip.Entries.Where(e => !e.IsDirectory && (e.FileName.StartsWith($"{sourceFolder.ToLower()}/", StringComparison.OrdinalIgnoreCase) || e.FileName.ToLower().Contains($"/{sourceFolder.ToLower()}/")))); + } else + { selection.AddRange(zip.Entries.Where(e => !e.IsDirectory && Path.GetDirectoryName(e.FileName).Equals(sourceFolder, StringComparison.OrdinalIgnoreCase))); + } foreach (var entry in selection) { @@ -140,7 +144,9 @@ namespace ServerManagerTool.Common.Utils zip.AddFiles(filesToZip.Where(f => !string.IsNullOrWhiteSpace(f) && File.Exists(f)), preserveDirHierarchy, directoryPathInArchive); if (!string.IsNullOrWhiteSpace(comment)) + { zip.Comment = comment; + } zip.Save(); } @@ -200,7 +206,9 @@ namespace ServerManagerTool.Common.Utils zip.CompressionLevel = Ionic.Zlib.CompressionLevel.Default; if (!string.IsNullOrWhiteSpace(comment)) + { zip.Comment = comment; + } zip.Save(zipFile); } @@ -212,7 +220,9 @@ namespace ServerManagerTool.Common.Utils zip.AddFile(fileToZip, directoryPath); if (!string.IsNullOrWhiteSpace(comment)) + { zip.Comment = comment; + } zip.Save(); } @@ -233,7 +243,34 @@ namespace ServerManagerTool.Common.Utils zip.CompressionLevel = Ionic.Zlib.CompressionLevel.Default; if (!string.IsNullOrWhiteSpace(comment)) + { zip.Comment = comment; + } + + zip.Save(); + } + } + + public static void ZipFiles(string zipFile, Dictionary> filesToZip, string comment = "") + { + if (string.IsNullOrWhiteSpace(zipFile)) + throw new ArgumentNullException(nameof(zipFile)); + + if (filesToZip is null || filesToZip.IsEmpty()) + throw new ArgumentNullException(nameof(filesToZip)); + + using (var zip = new ZipFile(zipFile)) + { + foreach (var zipFolder in filesToZip.Keys) + { + zip.AddFiles(filesToZip[zipFolder].Where(f => !string.IsNullOrWhiteSpace(f) && File.Exists(f)), false, zipFolder); + } + + zip.CompressionLevel = Ionic.Zlib.CompressionLevel.Default; + if (!string.IsNullOrWhiteSpace(comment)) + { + zip.Comment = comment; + } zip.Save(); }