diff options
| author | Joe Carstairs <me@joeac.net> | 2025-08-25 16:35:45 +0000 |
|---|---|---|
| committer | joeac <me@joeac.net> | 2025-08-25 16:35:45 +0000 |
| commit | fe85652e4d3e8906824baddaafd05d19105579b8 (patch) | |
| tree | 31b56e31cbf289a34ec1d6707becf3c60933b56f /schist_desktop_gui/src/connection.rs | |
| parent | d082a30de6a0cbd1fbe2ab5a4316db0891004129 (diff) | |
task-072
Co-authored-by: Joe Carstairs <jcarstairs@scottlogic.com>
Reviewed-on: https://git.joeac.net/joeac/schist/pulls/3
Co-authored-by: Joe Carstairs <me@joeac.net>
Co-committed-by: Joe Carstairs <me@joeac.net>
Diffstat (limited to 'schist_desktop_gui/src/connection.rs')
| -rw-r--r-- | schist_desktop_gui/src/connection.rs | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/schist_desktop_gui/src/connection.rs b/schist_desktop_gui/src/connection.rs deleted file mode 100644 index 5a88083..0000000 --- a/schist_desktop_gui/src/connection.rs +++ /dev/null @@ -1,20 +0,0 @@ -use std::{fs::create_dir_all, path::Path}; - -use anyhow::Context; -use diesel::{Connection, SqliteConnection}; - -const SCHIST_DATA_DIR: &'static str = "schist"; -const SCHIST_DATABASE_FILENAME: &'static str = "schist.sqlite"; - -pub fn establish_connection() -> anyhow::Result<SqliteConnection> { - let data_dir = dirs::data_dir().context("Failed to get local app data directory")?; - let schist_local_dir = data_dir.join(Path::new(SCHIST_DATA_DIR)); - create_dir_all(&schist_local_dir) - .context(format!("Failed to create local files directory at {}", schist_local_dir.display()))?; - let db_path = schist_local_dir.join(Path::new(SCHIST_DATABASE_FILENAME)); - let db_path = db_path - .to_str() - .context("Failed to construct database path")?; - Ok(SqliteConnection::establish(db_path) - .with_context(|| format!("Failed to connect to database at {}", db_path))?) -} |
