From 41da460bfc050d3ce534aed9f2a3051e896e238a Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Thu, 31 Jul 2025 10:39:21 +0200 Subject: [PATCH] update --- Pilz/Data/Json/JsonFileContainer.cs | 2 ++ Pilz/Data/Json/JsonStreamContainer.cs | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Pilz/Data/Json/JsonFileContainer.cs b/Pilz/Data/Json/JsonFileContainer.cs index 06fdac7..382f189 100644 --- a/Pilz/Data/Json/JsonFileContainer.cs +++ b/Pilz/Data/Json/JsonFileContainer.cs @@ -13,6 +13,8 @@ public class JsonFileContainer(string filePath) : JsonDataContainer using var sw = new StreamReader(filePath); GetSerializer().Populate(sw, this); } + else + sets.Clear(); } } diff --git a/Pilz/Data/Json/JsonStreamContainer.cs b/Pilz/Data/Json/JsonStreamContainer.cs index ce5876f..af49ab6 100644 --- a/Pilz/Data/Json/JsonStreamContainer.cs +++ b/Pilz/Data/Json/JsonStreamContainer.cs @@ -7,9 +7,14 @@ public class JsonStreamContainer(Stream stream) : JsonDataContainer { lock (_lock_StreamAction) { - using var sw = new StreamReader(stream); - stream.Position = 0; - GetSerializer().Populate(sw, this); + if (stream.Length != 0) + { + using var sw = new StreamReader(stream); + stream.Position = 0; + GetSerializer().Populate(sw, this); + } + else + sets.Clear(); } }