Skip to content

Commit

Permalink
Fix crash if .indi folder does not exist
Browse files Browse the repository at this point in the history
Fix #18
  • Loading branch information
MattBlack85 committed Mar 5, 2024
1 parent 45ac40f commit b766cfa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/backup/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ pub fn retrieve_db(paths: &Paths, token: &String) -> Result<(), String> {
.send()
{
Ok(r) => {
// Just make sure ~/.indi exists
match std::fs::create_dir(format!("{}/{}", paths.home_path, ".indi")) {
Ok(_) => (),
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => (),
Err(e) => panic!("IO error: {}", e),
};

let mut f = File::create("temp_backup.tar").unwrap();
f.write_all(r.as_bytes()).unwrap();
let mut arch = Archive::new(File::open("temp_backup.tar").unwrap());
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct CliArgs {
pub struct Paths {
folder_path: String,
logs_path: String,
home_path: String,
pub home_path: String,
db_path: String,
indi_conf_path: String,
}
Expand Down

0 comments on commit b766cfa

Please sign in to comment.