fix: interpret --config
flag properly
This commit is contained in:
parent
6460947ace
commit
221ba8268d
|
@ -22,9 +22,8 @@ pub struct DatasetMetadata {
|
|||
}
|
||||
|
||||
/// Return the path to the datasets file.
|
||||
fn datasets_path(config_dir: &Path) -> std::io::Result<PathBuf> {
|
||||
let mut path = config_dir.to_owned();
|
||||
path.push("startrnr");
|
||||
fn datasets_path(dir: &Path) -> std::io::Result<PathBuf> {
|
||||
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<PathBuf> {
|
|||
Ok(path)
|
||||
}
|
||||
|
||||
pub fn open_datasets(config_dir: &Path) -> sqlite::Result<Connection> {
|
||||
let path = datasets_path(config_dir).unwrap();
|
||||
pub fn open_datasets(dir: &Path) -> sqlite::Result<Connection> {
|
||||
let path = datasets_path(dir).unwrap();
|
||||
|
||||
let query = "
|
||||
CREATE TABLE IF NOT EXISTS datasets (
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue