diff --git a/src/backup/database.rs b/src/backup/database.rs index 0d6c174..488d43b 100644 --- a/src/backup/database.rs +++ b/src/backup/database.rs @@ -42,6 +42,17 @@ pub fn send_db(paths: &Paths, token: &String) -> Result<(), String> { Err(e) => panic!("Couldn't append the database to the archive, reason: {}", e), } + // Add fov.dat to the archive + let mut fov_db = match File::open(paths.fov_full_path()) { + Ok(f) => f, + Err(e) => panic!("Couldn't open the FOV database, reason: {}", e), + }; + + match arch.append_file("backup/kstars/fov.dat", &mut fov_db) { + Ok(_) => (), + Err(e) => panic!("Couldn't append the database to the archive, reason: {}", e), + } + match arch.finish() { Ok(_) => (), Err(e) => panic!("Couldn't create the archive, reason: {}", e), @@ -106,6 +117,8 @@ pub fn retrieve_db(paths: &Paths, token: &String) -> Result<(), String> { ); } else if path.to_str().unwrap().contains(&"mycity") { full_path = paths.city_db_full_path(); + } else if path.to_str().unwrap().contains(&"fov") { + full_path = paths.fov_full_path(); } else { full_path = paths.db_full_path(); }; diff --git a/src/lib.rs b/src/lib.rs index e0b380a..2348aeb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,6 +26,7 @@ pub struct Paths { db_path: String, city_db_path: String, indi_conf_path: String, + fov_path: String, } impl Paths { @@ -49,6 +50,11 @@ impl Paths { return db_path; } + pub fn fov_full_path(&self) -> String { + let path = format!("{}/{}", self.home_path, self.fov_path); + return path; + } + pub fn indi_conf_full_path(&self) -> String { let indi_conf_path = format!("{}/{}", self.home_path, self.indi_conf_path); return indi_conf_path; @@ -65,6 +71,7 @@ impl Paths { db_path: String::from("Library/Application Support/kstars/userdb.sqlite"), indi_conf_path: String::from(".indi/"), city_db_path: String::from(".local/share/kstars/mycitydb.sqlite"), + fov_path: String::from(".local/share/kstars/fov.dat"), } } }