From 13514b635c139f5bd9177b1b30b005d39045db54 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Mon, 20 Mar 2023 21:26:37 +0000 Subject: 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 * Bye bye unwrap --------- Co-authored-by: Conrad Ludgate --- atuin-client/src/encryption.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'atuin-client/src/encryption.rs') diff --git a/atuin-client/src/encryption.rs b/atuin-client/src/encryption.rs index c718d4da..40badb5e 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) } -- cgit v1.3.1