From f1c5a098fc22ef7f0262dff1e315495016cd8064 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Thu, 25 Feb 2021 10:31:08 -0800 Subject: [PATCH] fix(serialization): Skip backups on first save. Fixes timestamp format (#522) --- Projects/Server/Utilities/Utility.cs | 7 +------ Projects/UOContent/Misc/AutoSave.cs | 7 ++++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Projects/Server/Utilities/Utility.cs b/Projects/Server/Utilities/Utility.cs index 4935a8ed4..b9f4b8f88 100644 --- a/Projects/Server/Utilities/Utility.cs +++ b/Projects/Server/Utilities/Utility.cs @@ -1434,11 +1434,6 @@ namespace Server } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string GetTimeStamp() - { - var now = DateTime.UtcNow; - - return $"{now.Year}-{now.Month}-{now.Day} {now.Hour}-{now.Minute:D2}-{now.Second:D2}"; - } + public static string GetTimeStamp() => DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"); } } diff --git a/Projects/UOContent/Misc/AutoSave.cs b/Projects/UOContent/Misc/AutoSave.cs index aa585386d..6fe30ac7c 100644 --- a/Projects/UOContent/Misc/AutoSave.cs +++ b/Projects/UOContent/Misc/AutoSave.cs @@ -94,11 +94,16 @@ namespace Server.Misc private static void Backup(WorldSavePostSnapshotEventArgs args) { + if (!Directory.Exists(args.OldSavePath)) + { + return; + } + var backupPath = Path.Combine(BackupPath, Utility.GetTimeStamp()); AssemblyHandler.EnsureDirectory(BackupPath); Directory.Move(args.OldSavePath, backupPath); - Console.WriteLine("AutoSave: Created backup at {0}", backupPath); + Persistence.WriteConsole($"Created backup at {backupPath}"); } } }