From 221ba8268d95887cdb3f53603395696ad5b8710b Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Wed, 14 Aug 2024 20:56:57 -0400 Subject: [PATCH] fix: interpret `--config` flag properly --- src/database.rs | 9 ++++----- src/main.rs | 1 + src/queries.rs | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/database.rs b/src/database.rs index 5497837..d6eec7e 100644 --- a/src/database.rs +++ b/src/database.rs @@ -22,9 +22,8 @@ pub struct DatasetMetadata { } /// Return the path to the datasets file. -fn datasets_path(config_dir: &Path) -> std::io::Result { - let mut path = config_dir.to_owned(); - path.push("startrnr"); +fn datasets_path(dir: &Path) -> std::io::Result { + let mut path = dir.to_owned(); // Create datasets path if it doesn't exist fs::create_dir_all(&path)?; @@ -37,8 +36,8 @@ fn datasets_path(config_dir: &Path) -> std::io::Result { Ok(path) } -pub fn open_datasets(config_dir: &Path) -> sqlite::Result { - let path = datasets_path(config_dir).unwrap(); +pub fn open_datasets(dir: &Path) -> sqlite::Result { + let path = datasets_path(dir).unwrap(); let query = " CREATE TABLE IF NOT EXISTS datasets ( diff --git a/src/main.rs b/src/main.rs index aeae8c5..5f9aaea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -113,6 +113,7 @@ fn main() { let config_dir = cli .config_dir + .map(|mut s| { s.push("startrnr"); s }) .unwrap_or_else(|| dirs::config_dir().expect("Could not determine config directory")); let connection = open_datasets(&config_dir).unwrap_or_else(|_| error("Could not open datasets file", 2)); diff --git a/src/queries.rs b/src/queries.rs index 10278c6..e9a5ecc 100644 --- a/src/queries.rs +++ b/src/queries.rs @@ -28,7 +28,6 @@ pub fn get_auth_token(config_dir: &Path) -> String { Err(VarError::NotUnicode(_)) => error("Invalid authorization key", 2), Err(VarError::NotPresent) => { let mut auth_file = config_dir.to_owned(); - auth_file.push("startrnr"); auth_file.push("auth.txt"); read_to_string(auth_file) .ok()