Allow providing database location via config json (#801)

Closes #633 via VRCX_DatabaseLocation in VRCX.json
This commit is contained in:
Nekromateion
2024-05-29 00:58:03 +02:00
committed by GitHub
parent fd20b08823
commit 39b398abdb
2 changed files with 9 additions and 5 deletions

View File

@@ -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();

View File

@@ -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();
}