about summary refs log tree commit diff
path: root/corgi/src
diff options
context:
space:
mode:
Diffstat (limited to 'corgi/src')
-rw-r--r--corgi/src/stats.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/corgi/src/stats.rs b/corgi/src/stats.rs
index bf9c1ec..23e85a0 100644
--- a/corgi/src/stats.rs
+++ b/corgi/src/stats.rs
@@ -18,10 +18,26 @@ impl Stats {
 
 	pub fn create_tables(&self) {
 		let conn = self.conn.lock().unwrap();
+
+		Self::set_wal(&conn);
+
 		conn.execute(CREATE_TABLE_AGENT, ()).unwrap();
 		conn.execute(CREATE_TABLE_REQUESTS, ()).unwrap();
 	}
 
+	fn set_wal(conn: &Connection) {
+		let journal_mode: String = conn
+			.pragma_update_and_check(None, "journal_mode", "WAL", |row| row.get(0))
+			.unwrap();
+
+		match journal_mode.to_ascii_lowercase().as_str() {
+			"wal" => (),
+			_ => {
+				eprintln!("WARN sqlitedb did not successfully enter the WAL journal mode");
+			}
+		}
+	}
+
 	pub fn log_request(&self, request: Request) {
 		let Request {
 			agent,