From 2cde814aaa956c0eb90e810601348781a32bf617 Mon Sep 17 00:00:00 2001 From: BlackDex Date: Fri, 11 Oct 2019 12:08:40 +0200 Subject: [PATCH] Fixed a bug with the sqlite backup feature. When a custom path is used the backup feature does not work. Changed it so it will take the path of the sqlite file and use that. --- src/db/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/db/mod.rs b/src/db/mod.rs index a7a32eed..eabbcb4e 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -52,12 +52,16 @@ pub fn get_connection() -> Result { /// Creates a back-up of the database using sqlite3 pub fn backup_database() -> Result<(), Error> { + use std::path::Path; + let db_url = CONFIG.database_url(); + let db_path = Path::new(&db_url).parent().unwrap(); + let now: DateTime = Utc::now(); let file_date = now.format("%Y%m%d").to_string(); let backup_command: String = format!("{}{}{}", ".backup 'db_", file_date, ".sqlite3'"); Command::new("sqlite3") - .current_dir("./data") + .current_dir(db_path) .args(&["db.sqlite3", &backup_command]) .output() .expect("Can't open database, sqlite3 is not available, make sure it's installed and available on the PATH");