Backup Bugfixes

- fixed the zip utils to read the file contents before backup.
- added new content backup metho for support zip creation.
This commit is contained in:
Brett Hewitson 2022-05-08 20:07:13 +10:00
parent 5374f8c7da
commit 1fc9bc87e4
13 changed files with 143 additions and 80 deletions

View file

@ -321,7 +321,7 @@
<Compile Include="Lib\Model\Level.cs" />
<Compile Include="Lib\Server.cs" />
<Compile Include="Lib\ServerProfile.cs" />
<Compile Include="Lib\ServerRCON.cs" />
<Compile Include="Lib\ServerRcon.cs" />
<Compile Include="Lib\ServerApp.cs" />
<Compile Include="Lib\ServerRuntime.cs" />
<Compile Include="Lib\ViewConverters\DifficultyOffsetValueConverter.cs" />

View file

@ -2040,14 +2040,14 @@ namespace ServerManagerTool.Lib
var saveFolderInfo = new DirectoryInfo(saveFolder);
// backup the world save file
ZipUtils.ZipAFile(backupFile, worldFileName, worldFile, comment.ToString());
ZipUtils.ZipFile(backupFile, worldFileName, worldFile, comment.ToString());
// backup the player files
var playerFileFilter = $"*{Config.Default.PlayerFileExtension}";
var playerFiles = saveFolderInfo.GetFiles(playerFileFilter, SearchOption.TopDirectoryOnly);
foreach (var file in playerFiles)
{
ZipUtils.ZipAFile(backupFile, file.Name, file.FullName);
ZipUtils.ZipFile(backupFile, file.Name, file.FullName);
}
// backup the tribe files
@ -2055,7 +2055,7 @@ namespace ServerManagerTool.Lib
var tribeFiles = saveFolderInfo.GetFiles(tribeFileFilter, SearchOption.TopDirectoryOnly);
foreach (var file in tribeFiles)
{
ZipUtils.ZipAFile(backupFile, file.Name, file.FullName);
ZipUtils.ZipFile(backupFile, file.Name, file.FullName);
}
// backup the tribute tribe files
@ -2063,7 +2063,7 @@ namespace ServerManagerTool.Lib
var tributeTribeFiles = saveFolderInfo.GetFiles(tributeTribeFileFilter, SearchOption.TopDirectoryOnly);
foreach (var file in tributeTribeFiles)
{
ZipUtils.ZipAFile(backupFile, file.Name, file.FullName);
ZipUtils.ZipFile(backupFile, file.Name, file.FullName);
}
if (Config.Default.AutoBackup_IncludeSaveGamesFolder)
@ -2078,7 +2078,7 @@ namespace ServerManagerTool.Lib
var saveGamesFiles = saveGamesFolderInfo.GetFiles(saveGamesFileFilter, SearchOption.AllDirectories);
foreach (var file in saveGamesFiles)
{
ZipUtils.ZipAFile(backupFile, file.FullName.Replace(saveGamesFolder, Config.Default.SaveGamesRelativePath), file.FullName);
ZipUtils.ZipFile(backupFile, file.FullName.Replace(saveGamesFolder, Config.Default.SaveGamesRelativePath), file.FullName);
}
}
}
@ -2365,10 +2365,10 @@ namespace ServerManagerTool.Lib
switch (commandValue.ToLower())
{
case "global":
return ServerRCON.RCON_COMMAND_SERVERCHAT;
return ServerRcon.RCON_COMMAND_SERVERCHAT;
default:
return ServerRCON.RCON_COMMAND_BROADCAST;
return ServerRcon.RCON_COMMAND_BROADCAST;
}
}

View file

@ -7,12 +7,10 @@ using ServerManagerTool.Common.Lib;
using ServerManagerTool.Common.Model;
using ServerManagerTool.Common.Utils;
using ServerManagerTool.Enums;
using ServerManagerTool.Lib.ViewModel;
using ServerManagerTool.Lib.ViewModel.RCON;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Net;
@ -23,7 +21,7 @@ using WPFSharp.Globalizer;
namespace ServerManagerTool.Lib
{
public class ServerRCON : DependencyObject, IAsyncDisposable
public class ServerRcon : DependencyObject, IAsyncDisposable
{
private const int STEAM_UPDATE_INTERVAL = 60;
private const int PLAYER_LIST_INTERVAL = 5000;
@ -39,11 +37,11 @@ namespace ServerManagerTool.Lib
public event EventHandler PlayersCollectionUpdated;
public static readonly DependencyProperty StatusProperty = DependencyProperty.Register(nameof(Status), typeof(ConsoleStatus), typeof(ServerRCON), new PropertyMetadata(ConsoleStatus.Disconnected));
public static readonly DependencyProperty PlayersProperty = DependencyProperty.Register(nameof(Players), typeof(SortableObservableCollection<PlayerInfo>), typeof(ServerRCON), new PropertyMetadata(null));
public static readonly DependencyProperty CountPlayersProperty = DependencyProperty.Register(nameof(CountPlayers), typeof(int), typeof(ServerRCON), new PropertyMetadata(0));
public static readonly DependencyProperty CountInvalidPlayersProperty = DependencyProperty.Register(nameof(CountInvalidPlayers), typeof(int), typeof(ServerRCON), new PropertyMetadata(0));
public static readonly DependencyProperty CountOnlinePlayersProperty = DependencyProperty.Register(nameof(CountOnlinePlayers), typeof(int), typeof(ServerRCON), new PropertyMetadata(0));
public static readonly DependencyProperty StatusProperty = DependencyProperty.Register(nameof(Status), typeof(ConsoleStatus), typeof(ServerRcon), new PropertyMetadata(ConsoleStatus.Disconnected));
public static readonly DependencyProperty PlayersProperty = DependencyProperty.Register(nameof(Players), typeof(SortableObservableCollection<PlayerInfo>), typeof(ServerRcon), new PropertyMetadata(null));
public static readonly DependencyProperty CountPlayersProperty = DependencyProperty.Register(nameof(CountPlayers), typeof(int), typeof(ServerRcon), new PropertyMetadata(0));
public static readonly DependencyProperty CountInvalidPlayersProperty = DependencyProperty.Register(nameof(CountInvalidPlayers), typeof(int), typeof(ServerRcon), new PropertyMetadata(0));
public static readonly DependencyProperty CountOnlinePlayersProperty = DependencyProperty.Register(nameof(CountOnlinePlayers), typeof(int), typeof(ServerRcon), new PropertyMetadata(0));
private static readonly char[] lineSplitChars = new char[] { '\n' };
private static readonly char[] argsSplitChars = new char[] { ' ' };
@ -67,7 +65,7 @@ namespace ServerManagerTool.Lib
private readonly Logger _errorLogger;
private bool _disposed = false;
public ServerRCON(RCONParameters parameters)
public ServerRcon(RCONParameters parameters)
{
_rconParameters = parameters;
@ -363,20 +361,23 @@ namespace ServerManagerTool.Lib
onlinePlayers.Add(newPlayer);
var playerJoined = false;
_players.AddOrUpdate(newPlayer.PlayerId,
(k) =>
{
playerJoined = true;
return newPlayer;
},
(k, v) =>
{
playerJoined = !v.IsOnline;
v.PlayerName = newPlayer.PlayerName;
v.IsOnline = newPlayer.IsOnline;
return v;
}
);
if (!string.IsNullOrWhiteSpace(newPlayer.PlayerName))
{
_players.AddOrUpdate(newPlayer.PlayerId,
(k) =>
{
playerJoined = true;
return newPlayer;
},
(k, v) =>
{
playerJoined = !v.IsOnline;
v.PlayerName = newPlayer.PlayerName;
v.IsOnline = newPlayer.IsOnline;
return v;
}
);
}
if (playerJoined)
{

View file

@ -952,7 +952,7 @@ namespace ServerManagerTool
ZipUtils.ZipFiles(zipFile, files, comment.ToString());
foreach (var kvp in obfuscateFiles)
{
ZipUtils.ZipAFile(zipFile, kvp.Key, kvp.Value);
ZipUtils.ZipContent(zipFile, kvp.Key, kvp.Value);
}
var message = _globalizer.GetResourceString("ServerSettings_SupportZipSuccessLabel").Replace("{filename}", Path.GetFileName(zipFile));

View file

@ -9,13 +9,18 @@
<entry>
<id>urn:uuid:2C48A585-72D2-43FB-8987-6B5F0B3E460F</id>
<title>1.1.425 (1.1.425.5)</title>
<summary>1.1.425.5</summary>
<title>1.1.425 (1.1.425.6)</title>
<summary>1.1.425.6</summary>
<link href="" />
<updated>2022-05-08T00:00:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
<p>
<u style="font-size: .9em;">BUGFIX</u>
<br/>
<ul>
<li>World Save Backup - fixed the backup of the files.</li>
</ul>
<u style="font-size: .9em;">CHANGE</u>
<br/>
<ul>

View file

@ -7,6 +7,29 @@
<link href="http://arkservermanager.freeforums.net/" />
<updated>2022-05-08T00:00:00Z</updated>
<entry>
<id>urn:uuid:973E001F-223C-4B57-89F7-8B8040900A7C</id>
<title>1.1.425 (1.1.425.6)</title>
<summary>1.1.425.6</summary>
<link href="" />
<updated>2022-05-08T00:00:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
<p>
<u style="font-size: .9em;">BUGFIX</u>
<br/>
<ul>
<li>World Save Backup - fixed the backup of the files.</li>
</ul>
</p>
</div>
</content>
<author>
<name>bletch</name>
<email>bletch1971@hotmail.com</email>
</author>
</entry>
<entry>
<id>urn:uuid:CEA21F86-5943-46F9-8807-604695E42A25</id>
<title>1.1.425 (1.1.425.5)</title>

View file

@ -176,7 +176,7 @@ namespace ServerManagerTool
public static readonly DependencyProperty PlayersViewProperty = DependencyProperty.Register(nameof(PlayersView), typeof(ICollectionView), typeof(RCONWindow), new PropertyMetadata(null));
public static readonly DependencyProperty RCONParametersProperty = DependencyProperty.Register(nameof(RCONParameters), typeof(RCONParameters), typeof(RCONWindow), new PropertyMetadata(null));
public static readonly DependencyProperty ScrollOnNewInputProperty = DependencyProperty.Register(nameof(ScrollOnNewInput), typeof(bool), typeof(RCONWindow), new PropertyMetadata(true));
public static readonly DependencyProperty ServerRCONProperty = DependencyProperty.Register(nameof(ServerRCON), typeof(ServerRCON), typeof(RCONWindow), new PropertyMetadata(null));
public static readonly DependencyProperty ServerRCONProperty = DependencyProperty.Register(nameof(ServerRCON), typeof(ServerRcon), typeof(RCONWindow), new PropertyMetadata(null));
public RCONWindow(RCONParameters parameters)
{
@ -187,7 +187,7 @@ namespace ServerManagerTool
this.PlayerFiltering = (PlayerFilterType)Config.Default.RCON_PlayerListFilter;
this.PlayerSorting = (PlayerSortType)Config.Default.RCON_PlayerListSort;
this.RCONParameters = parameters;
this.ServerRCON = new ServerRCON(parameters);
this.ServerRCON = new ServerRcon(parameters);
this.ServerRCON.RegisterCommandListener(RenderRCONCommandOutput);
this.ServerRCON.Players.CollectionChanged += Players_CollectionChanged;
this.ServerRCON.PlayersCollectionUpdated += Players_CollectionUpdated;
@ -195,7 +195,7 @@ namespace ServerManagerTool
this.PlayersView = CollectionViewSource.GetDefaultView(this.ServerRCON.Players);
this.PlayersView.Filter = new Predicate<object>(PlayerFilter);
var notifier = new PropertyChangeNotifier(this.ServerRCON, ServerRCON.StatusProperty, (o, e) =>
var notifier = new PropertyChangeNotifier(this.ServerRCON, ServerRcon.StatusProperty, (o, e) =>
{
this.RenderConnectionStateChange(e);
});
@ -301,9 +301,9 @@ namespace ServerManagerTool
set { SetValue(ScrollOnNewInputProperty, value); }
}
public ServerRCON ServerRCON
public ServerRcon ServerRCON
{
get { return (ServerRCON)GetValue(ServerRCONProperty); }
get { return (ServerRcon)GetValue(ServerRCONProperty); }
set { SetValue(ServerRCONProperty, value); }
}
#endregion
@ -461,7 +461,7 @@ namespace ServerManagerTool
var message = _globalizer.GetResourceString("RCON_DestroyWildDinosLabel");
this.ServerRCON.IssueCommand($"{Config.Default.RCON_MessageCommand.ToLower()} {message}");
this.ServerRCON.IssueCommand(ServerRCON.RCON_COMMAND_WILDDINOWIPE);
this.ServerRCON.IssueCommand(ServerRcon.RCON_COMMAND_WILDDINOWIPE);
},
canExecute: (_) => true
);
@ -807,17 +807,17 @@ namespace ServerManagerTool
break;
case InputMode.Broadcast:
this.ServerRCON.IssueCommand($"{ServerRCON.RCON_COMMAND_BROADCAST} {commandText}");
this.ServerRCON.IssueCommand($"{ServerRcon.RCON_COMMAND_BROADCAST} {commandText}");
break;
case InputMode.Global:
if (!String.IsNullOrWhiteSpace(Config.Default.RCON_AdminName))
{
this.ServerRCON.IssueCommand($"{ServerRCON.RCON_COMMAND_SERVERCHAT} [{Config.Default.RCON_AdminName}] {commandText}");
this.ServerRCON.IssueCommand($"{ServerRcon.RCON_COMMAND_SERVERCHAT} [{Config.Default.RCON_AdminName}] {commandText}");
}
else
{
this.ServerRCON.IssueCommand($"{ServerRCON.RCON_COMMAND_SERVERCHAT} {commandText}");
this.ServerRCON.IssueCommand($"{ServerRcon.RCON_COMMAND_SERVERCHAT} {commandText}");
}
break;
}
@ -914,7 +914,7 @@ namespace ServerManagerTool
private IEnumerable<Inline> FormatCommandInput(ConsoleCommand command)
{
if (command.command.Equals(ServerRCON.RCON_COMMAND_BROADCAST, StringComparison.OrdinalIgnoreCase))
if (command.command.Equals(ServerRcon.RCON_COMMAND_BROADCAST, StringComparison.OrdinalIgnoreCase))
{
yield return new RCONOutput_Broadcast(command.args);
}
@ -933,7 +933,7 @@ namespace ServerManagerTool
{
bool firstLine = true;
if (command.command.Equals(ServerRCON.RCON_COMMAND_LISTPLAYERS, StringComparison.OrdinalIgnoreCase))
if (command.command.Equals(ServerRcon.RCON_COMMAND_LISTPLAYERS, StringComparison.OrdinalIgnoreCase))
{
foreach (var output in command.lines)
{
@ -945,7 +945,7 @@ namespace ServerManagerTool
}
firstLine = false;
if (trimmed == ServerRCON.NoResponseOutput)
if (trimmed == ServerRcon.NoResponseOutput)
{
yield return new RCONOutput_NoResponse();
}
@ -975,7 +975,7 @@ namespace ServerManagerTool
}
firstLine = false;
if (trimmed == ServerRCON.NoResponseOutput)
if (trimmed == ServerRcon.NoResponseOutput)
{
yield return new RCONOutput_NoResponse();
}