Skip to content

Commit

Permalink
Merge pull request #8 from is-it-ayush/ayu/dont_create_store_if_encry…
Browse files Browse the repository at this point in the history
…ption_fails

fix: don't create store if encryption is denied.
  • Loading branch information
is-it-ayush authored Dec 25, 2023
2 parents 0150bb7 + dfc1ca3 commit 4fc390b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ impl Store {
.create(true)
.append(false)
.open(&store_path)?;
let encrypted_data = Gpg::encrypt(fingerprint, &String::new())?;

let encrypted_data = match Gpg::encrypt(fingerprint, &String::new()) {
Ok(d) => d,
Err(e) => {
fs::remove_file(&store_path)?;
return Err(e);
}
};
store_file.write_all(&encrypted_data)?;
let store_path_string = store_path
.to_str()
Expand Down

0 comments on commit 4fc390b

Please sign in to comment.