From 39b398abdb6e28e870137c56d2725e0b31e08901 Mon Sep 17 00:00:00 2001 From: Nekromateion <43814053+Nekromateion@users.noreply.github.com> Date: Wed, 29 May 2024 00:58:03 +0200 Subject: [PATCH] Allow providing database location via config json (#801) Closes #633 via VRCX_DatabaseLocation in VRCX.json --- Dotnet/Program.cs | 2 +- Dotnet/SQLiteLegacy.cs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Dotnet/Program.cs b/Dotnet/Program.cs index f5987362..316d4d70 100644 --- a/Dotnet/Program.cs +++ b/Dotnet/Program.cs @@ -142,8 +142,8 @@ namespace VRCX ProcessMonitor.Instance.Init(); - SQLiteLegacy.Instance.Init(); VRCXStorage.Load(); + SQLiteLegacy.Instance.Init(); CpuMonitor.Instance.Init(); Discord.Instance.Init(); WorldDBManager.Instance.Init(); diff --git a/Dotnet/SQLiteLegacy.cs b/Dotnet/SQLiteLegacy.cs index 4d0874b8..f9be6003 100644 --- a/Dotnet/SQLiteLegacy.cs +++ b/Dotnet/SQLiteLegacy.cs @@ -11,7 +11,7 @@ namespace VRCX { public static readonly SQLiteLegacy Instance; private readonly ReaderWriterLockSlim m_ConnectionLock; - private readonly SQLiteConnection m_Connection; + private SQLiteConnection m_Connection; static SQLiteLegacy() { @@ -21,13 +21,17 @@ namespace VRCX public SQLiteLegacy() { m_ConnectionLock = new ReaderWriterLockSlim(); - - var dataSource = Program.ConfigLocation; - m_Connection = new SQLiteConnection($"Data Source=\"{dataSource}\";Version=3;PRAGMA locking_mode=NORMAL;PRAGMA busy_timeout=5000", true); } internal void Init() { + var dataSource = Program.ConfigLocation; + var jsonDataSource = VRCXStorage.Instance.Get("VRCX_DatabaseLocation"); + if (!string.IsNullOrEmpty(jsonDataSource)) + dataSource = jsonDataSource; + + m_Connection = new SQLiteConnection($"Data Source=\"{dataSource}\";Version=3;PRAGMA locking_mode=NORMAL;PRAGMA busy_timeout=5000", true); + m_Connection.Open(); }