mirror of
https://github.com/atuinsh/atuin.git
synced 2024-12-25 16:39:18 +01:00
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.
This commit is contained in:
parent
9597080825
commit
335f2220c3
@ -32,6 +32,11 @@ pub struct EncryptedHistory {
|
|||||||
|
|
||||||
pub fn new_key(settings: &Settings) -> Result<Key> {
|
pub fn new_key(settings: &Settings) -> Result<Key> {
|
||||||
let path = settings.key_path.as_str();
|
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 key = XSalsa20Poly1305::generate_key(&mut OsRng);
|
||||||
let encoded = encode_key(&key)?;
|
let encoded = encode_key(&key)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user