aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-client
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2024-01-30 14:01:20 +0000
committerGitHub <noreply@github.com>2024-01-30 14:01:20 +0000
commit335f2220c3199055c68a444a84e452d95824e764 (patch)
treef4a3d693fda0ee0515cc18b09dd9b535a343eec2 /atuin-client
parentfeat: add store push (#1649) (diff)
downloadatuin-335f2220c3199055c68a444a84e452d95824e764.zip
fix: never overwrite the key (#1657)
Now that local history is stored encrypted, new_key should not overwrite an existing one. This may be frustrating, but will remove the risk of Atuin generating a new key and the user losing their old one.
Diffstat (limited to 'atuin-client')
-rw-r--r--atuin-client/src/encryption.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/atuin-client/src/encryption.rs b/atuin-client/src/encryption.rs
index 3c9f3d06..f4031059 100644
--- a/atuin-client/src/encryption.rs
+++ b/atuin-client/src/encryption.rs
@@ -32,6 +32,11 @@ pub struct EncryptedHistory {
pub fn new_key(settings: &Settings) -> Result<Key> {
let path = settings.key_path.as_str();
+ let path = PathBuf::from(path);
+
+ if path.exists() {
+ bail!("key already exists! cannot overwrite");
+ }
let key = XSalsa20Poly1305::generate_key(&mut OsRng);
let encoded = encode_key(&key)?;