diff --git a/HellionChat/MessageStore.cs b/HellionChat/MessageStore.cs index 9aa3bfe..fd4378d 100644 --- a/HellionChat/MessageStore.cs +++ b/HellionChat/MessageStore.cs @@ -198,22 +198,31 @@ internal class MessageStore : IDisposable Connection.Dispose(); } - private SqliteConnection Connect() + private static string BuildConnectionString(string dbPath) { var uriBuilder = new SqliteConnectionStringBuilder { - DataSource = DbPath, + DataSource = dbPath, DefaultTimeout = 5, Pooling = false, Mode = SqliteOpenMode.ReadWriteCreate, }; + return uriBuilder.ToString(); + } - var conn = new SqliteConnection(uriBuilder.ToString()); - conn.Open(); + private void ApplyPragmas(SqliteConnection conn) + { conn.Execute(@"PRAGMA journal_mode=WAL;"); conn.Execute(@"PRAGMA synchronous=NORMAL;"); if (_platformUtil.IsWine) conn.Execute(@"PRAGMA cache_size = 32768;"); + } + + private SqliteConnection Connect() + { + var conn = new SqliteConnection(BuildConnectionString(DbPath)); + conn.Open(); + ApplyPragmas(conn); return conn; }