Skip to content

Commit

Permalink
Fix database location when running with --testing
Browse files Browse the repository at this point in the history
  • Loading branch information
johan-bjareholt committed Apr 4, 2020
1 parent 335417e commit 642a531
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion aw-server/src/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub mod android {
match DATASTORE {
Some(ref ds) => ds.clone(),
None => {
let db_dir = dirs::db_path().to_str().unwrap().to_string();
let db_dir = dirs::db_path(false).to_str().unwrap().to_string();
DATASTORE = Some(Datastore::new(db_dir, false));
openDatastore()
}
Expand Down
11 changes: 6 additions & 5 deletions aw-server/src/dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ pub fn get_log_dir() -> Result<PathBuf, ()> {
}
}

pub fn db_path() -> PathBuf {
pub fn db_path(testing: bool) -> PathBuf {
let mut db_path = get_data_dir().unwrap();
#[cfg(debug_assertions)]
db_path.push("sqlite-testing.db");
#[cfg(not(debug_assertions))]
db_path.push("sqlite.db");
if testing {
db_path.push("sqlite-testing.db");
} else {
db_path.push("sqlite.db");
}
db_path
}

Expand Down
2 changes: 1 addition & 1 deletion aw-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn main() {

let config = config::create_config(testing);

let db_path = dirs::db_path().to_str().unwrap().to_string();
let db_path = dirs::db_path(testing).to_str().unwrap().to_string();
info!("Using DB at path {:?}", db_path);

let asset_path = get_asset_path();
Expand Down

0 comments on commit 642a531

Please sign in to comment.