From 9f1df5de803492ab3e690244281b7168e8d20921 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Wed, 15 Mar 2017 08:33:38 +0100 Subject: [PATCH] Assert on invalid json being saved --- ArchiSteamFarm/BotDatabase.cs | 5 +++++ ArchiSteamFarm/GlobalDatabase.cs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ArchiSteamFarm/BotDatabase.cs b/ArchiSteamFarm/BotDatabase.cs index 74d603b4c..684af745f 100644 --- a/ArchiSteamFarm/BotDatabase.cs +++ b/ArchiSteamFarm/BotDatabase.cs @@ -115,6 +115,11 @@ namespace ArchiSteamFarm { return; } + // This call verifies if JSON is alright + // We don't wrap it in try catch as it should always be the case + // And if it's not, we want to know about it (in a crash) and correc itt in future version + JsonConvert.DeserializeObject(json); + lock (FileLock) { for (byte i = 0; i < 5; i++) { try { diff --git a/ArchiSteamFarm/GlobalDatabase.cs b/ArchiSteamFarm/GlobalDatabase.cs index 9d0d250ab..34503c555 100644 --- a/ArchiSteamFarm/GlobalDatabase.cs +++ b/ArchiSteamFarm/GlobalDatabase.cs @@ -116,6 +116,11 @@ namespace ArchiSteamFarm { return; } + // This call verifies if JSON is alright + // We don't wrap it in try catch as it should always be the case + // And if it's not, we want to know about it (in a crash) and correc itt in future version + JsonConvert.DeserializeObject(json); + lock (FileLock) { for (byte i = 0; i < 5; i++) { try {