diff --git a/RSND/Core/Database.cs b/RSND/Core/Database.cs index 67581fe..9cc163a 100644 --- a/RSND/Core/Database.cs +++ b/RSND/Core/Database.cs @@ -20,7 +20,7 @@ public class Database { if (File.Exists($"{Name}.json")) { - Console.WriteLine($"{Name} flag123"); + Console.WriteLine($"[{Name}] The file exists."); var json = File.ReadAllText($"{Name}.json"); var db = JsonConvert.DeserializeObject>(json); if (db != null) @@ -28,14 +28,23 @@ public class Database } else { - Console.WriteLine($"{Name} flag"); + Console.WriteLine($"[{Name}] The file is getting created."); File.Create($"{Name}.json"); } } public void Save() { - var json = JsonConvert.SerializeObject(_tables); - File.WriteAllText($"{Name}.json", json); + try + { + var json = JsonConvert.SerializeObject(_tables); + File.WriteAllText($"{Name}.json", json); + } + catch + { + // slim chance there might be file structure issues. + // let's attempt to fix that. + SetupFiles(); + } } public void CreateTable(Table query)