diff options
author | Ellie Huxtable <ellie@elliehuxtable.com> | 2023-03-20 21:26:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-20 21:26:37 +0000 |
commit | 13514b635c139f5bd9177b1b30b005d39045db54 (patch) | |
tree | cba6329f67a18f50b97a5c8e3a65ddbee1302295 /atuin-client/src/encryption.rs | |
parent | 26a1b93098407c51b57508da7ab8050c2a1ee516 (diff) |
Support old msgpack (#794)
* Support old msgpack
I forgot it isn't backwards compatible... This should fix any sync
issues resulting from the deletion PR
* Update atuin-client/src/encryption.rs
Co-authored-by: Conrad Ludgate <conradludgate@gmail.com>
* Bye bye unwrap
---------
Co-authored-by: Conrad Ludgate <conradludgate@gmail.com>
Diffstat (limited to 'atuin-client/src/encryption.rs')
-rw-r--r-- | atuin-client/src/encryption.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/atuin-client/src/encryption.rs b/atuin-client/src/encryption.rs index c718d4dac..40badb5ed 100644 --- a/atuin-client/src/encryption.rs +++ b/atuin-client/src/encryption.rs @@ -15,7 +15,10 @@ use fs_err as fs; use serde::{Deserialize, Serialize}; use sodiumoxide::crypto::secretbox; -use crate::{history::History, settings::Settings}; +use crate::{ + history::{History, HistoryWithoutDelete}, + settings::Settings, +}; #[derive(Debug, Serialize, Deserialize)] pub struct EncryptedHistory { @@ -98,7 +101,23 @@ pub fn decrypt(encrypted_history: &EncryptedHistory, key: &secretbox::Key) -> Re let plaintext = secretbox::open(&encrypted_history.ciphertext, &encrypted_history.nonce, key) .map_err(|_| eyre!("failed to open secretbox - invalid key?"))?; - let history = rmp_serde::from_slice(&plaintext)?; + let history = rmp_serde::from_slice(&plaintext); + + let Ok(history) = history else { + let history: HistoryWithoutDelete = rmp_serde::from_slice(&plaintext)?; + + return Ok(History { + id: history.id, + cwd: history.cwd, + exit: history.exit, + command: history.command, + session: history.session, + duration: history.duration, + hostname: history.hostname, + timestamp: history.timestamp, + deleted_at: None, + }); + }; Ok(history) } |