From dfc1ca3a183925b0c26fba0380d2b9012b72a371 Mon Sep 17 00:00:00 2001 From: Ayush Gupta Date: Mon, 25 Dec 2023 16:29:32 +0530 Subject: [PATCH] fix: don't create store if encryption is denied. --- src/store.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/store.rs b/src/store.rs index 7c4edf6..c8f2d19 100644 --- a/src/store.rs +++ b/src/store.rs @@ -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()