From 14d5f5595cae0796d0f9fac78c721b80ea4230d1 Mon Sep 17 00:00:00 2001 From: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com> Date: Fri, 15 Nov 2024 20:25:54 -0800 Subject: [PATCH] Fix gamedb fixes 9fd58a766ab34e8aa98f9b6f0feb725474e346ac --- src/BizHawk.Emulation.Common/Database/Database.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/BizHawk.Emulation.Common/Database/Database.cs b/src/BizHawk.Emulation.Common/Database/Database.cs index b826ef7538..4711c20adb 100644 --- a/src/BizHawk.Emulation.Common/Database/Database.cs +++ b/src/BizHawk.Emulation.Common/Database/Database.cs @@ -92,6 +92,7 @@ namespace BizHawk.Emulation.Common .Append(gameInfo.MetaData) .Append(Environment.NewLine); + _acquire.WaitOne(); File.AppendAllText(Path.Combine(_userRoot, filename), sb.ToString()); DB = DB.Append(new(gameInfo.Hash, gameInfo)).ToFrozenDictionary(); } @@ -159,7 +160,7 @@ namespace BizHawk.Emulation.Common if (!inUser) _expected.Remove(Path.GetFileName(path)); //reminder: this COULD be done on several threads, if it takes even longer using var reader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)); - while (reader.ReadLine() is string line) + while (reader.ReadLine() is { } line) { try { @@ -200,8 +201,6 @@ namespace BizHawk.Emulation.Common Util.DebugWriteLine($"Error parsing database entry: {line}"); } } - DB = _builder.ToFrozenDictionary(); - _builder.Clear(); } public static void InitializeDatabase(string bundledRoot, string userRoot, bool silent) @@ -217,6 +216,8 @@ namespace BizHawk.Emulation.Common var stopwatch = Stopwatch.StartNew(); ThreadPool.QueueUserWorkItem(_ => { InitializeWork(Path.Combine(bundledRoot, "gamedb.txt"), inUser: false, silent: silent); + DB = _builder.ToFrozenDictionary(); + _builder.Clear(); if (_expected.Count is not 0) Util.DebugWriteLine($"extra bundled gamedb files were not #included: {string.Join(", ", _expected)}"); Util.DebugWriteLine("GameDB load: " + stopwatch.Elapsed + " sec"); _acquire.Set();