diff --git a/Projects/Server/Main.cs b/Projects/Server/Main.cs index 535327cbe8..44e84f0fc6 100644 --- a/Projects/Server/Main.cs +++ b/Projects/Server/Main.cs @@ -517,10 +517,11 @@ public static void RunEventLoop() DoKill(_restartOnKill); } + // This is generally called from background threads during Preserialize internal static void RequestSnapshot(string snapshotPath) { - _performSnapshot = true; _snapshotPath = snapshotPath; + _performSnapshot = true; // Set this after the path so race conditions do not occur } public static void VerifySerialization() diff --git a/Projects/Server/World/World.cs b/Projects/Server/World/World.cs index 234c76d0b5..6a11c4f82d 100644 --- a/Projects/Server/World/World.cs +++ b/Projects/Server/World/World.cs @@ -324,6 +324,11 @@ internal static void Snapshot(string snapshotPath) { _serializationStart = Core.Now; + if (string.IsNullOrEmpty(snapshotPath)) + { + throw new ArgumentException("Snapshot path cannot be null or empty", nameof(snapshotPath)); + } + Persistence.SerializeAll(); PauseSerializationThreads(); EventSink.InvokeWorldSave();