diff options
| author | Ellie Huxtable <ellie@elliehuxtable.com> | 2024-01-30 14:01:20 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-30 14:01:20 +0000 |
| commit | 335f2220c3199055c68a444a84e452d95824e764 (patch) | |
| tree | f4a3d693fda0ee0515cc18b09dd9b535a343eec2 | |
| parent | feat: add store push (#1649) (diff) | |
| download | atuin-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.
| -rw-r--r-- | atuin-client/src/encryption.rs | 5 |
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)?; |
