fix(serialization): Skip backups on first save. Fixes timestamp format (#522)

This commit is contained in:
Kamron Batman 2021-02-25 10:31:08 -08:00 committed by GitHub
parent 8d54d273a4
commit f1c5a098fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -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");
}
}

View file

@ -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}");
}
}
}