From e6c4beddee8f02236b96da76654f169c8ff72a36 Mon Sep 17 00:00:00 2001 From: glihm Date: Wed, 25 Oct 2023 16:43:45 -0600 Subject: [PATCH] use file database instead of memory --- .gitignore | 1 + README.md | 2 +- src/db.rs | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index cb2afbf..9e8b22a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target .env .users +data.db diff --git a/README.md b/README.md index f99f41a..89ef28b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ To work, the `katana-ci` binary must be deployed on a server with docker install ## Design To keep things simple and flexible for CI, the `katana-ci` uses docker under the hood. -With an `in-memory` database for now, each user have an `api-key` that allows the `start` and `stop` of a Katana instance. +With an `file` database for now, each user have an `api-key` that allows the `start` and `stop` of a Katana instance. When a user starts an instance, a new container is created and started. The database trait `ProxifierDb` is for now targetting `Sqlite`, but may be reworked to support any backend supported by `sqlx` rust crate. diff --git a/src/db.rs b/src/db.rs index 12fb780..4ba8340 100644 --- a/src/db.rs +++ b/src/db.rs @@ -3,9 +3,9 @@ use async_trait::async_trait; //use regex::Regex; use sqlx::{sqlite::SqliteConnectOptions, Error as SqlxError, FromRow, SqlitePool}; - use tracing::trace; use uuid::Uuid; +use std::str::FromStr; /// Errors for DB operations. #[derive(Debug, thiserror::Error)] @@ -79,7 +79,7 @@ impl SqlxDb { pub async fn new_any(_db_url: &str) -> Result { Ok(Self { pool: SqlitePool::connect_with( - SqliteConnectOptions::new().filename("file::memory:?cache=shared"), + SqliteConnectOptions::from_str("sqlite:data.db")? ) .await?, })