From 93582696fe5c2a9364dc8d9f9126cba79ca2da79 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Tue, 1 Dec 2020 23:32:00 +0100 Subject: [PATCH] Avoid attempting to save database without a FilePath --- ArchiSteamFarm/BotDatabase.cs | 8 +++++++- ArchiSteamFarm/GlobalDatabase.cs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ArchiSteamFarm/BotDatabase.cs b/ArchiSteamFarm/BotDatabase.cs index dafff03a0..d5dbd87f7 100644 --- a/ArchiSteamFarm/BotDatabase.cs +++ b/ArchiSteamFarm/BotDatabase.cs @@ -198,7 +198,13 @@ namespace ArchiSteamFarm { Utilities.InBackground(Save); } - private async void OnObjectModified(object? sender, EventArgs e) => await Save().ConfigureAwait(false); + private async void OnObjectModified(object? sender, EventArgs e) { + if (string.IsNullOrEmpty(FilePath)) { + return; + } + + await Save().ConfigureAwait(false); + } // ReSharper disable UnusedMember.Global public bool ShouldSerializeBackingLoginKey() => !string.IsNullOrEmpty(BackingLoginKey); diff --git a/ArchiSteamFarm/GlobalDatabase.cs b/ArchiSteamFarm/GlobalDatabase.cs index 285f44704..453cf6c1d 100644 --- a/ArchiSteamFarm/GlobalDatabase.cs +++ b/ArchiSteamFarm/GlobalDatabase.cs @@ -221,7 +221,13 @@ namespace ArchiSteamFarm { } } - private async void OnObjectModified(object? sender, EventArgs e) => await Save().ConfigureAwait(false); + private async void OnObjectModified(object? sender, EventArgs e) { + if (string.IsNullOrEmpty(FilePath)) { + return; + } + + await Save().ConfigureAwait(false); + } // ReSharper disable UnusedMember.Global public bool ShouldSerializeBackingCellID() => BackingCellID != 0;