Skip to content

Commit

Permalink
Add fov.dat to backup
Browse files Browse the repository at this point in the history
  • Loading branch information
MattBlack85 committed Mar 5, 2024
1 parent b0cd1fb commit 31198df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/backup/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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();
};
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct Paths {
db_path: String,
city_db_path: String,
indi_conf_path: String,
fov_path: String,
}

impl Paths {
Expand All @@ -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;
Expand All @@ -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"),
}
}
}

0 comments on commit 31198df

Please sign in to comment.