diff --git a/atuin-client/src/encryption.rs b/atuin-client/src/encryption.rs index c718d4d..40badb5 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) } diff --git a/atuin-client/src/history.rs b/atuin-client/src/history.rs index f377861..a710db2 100644 --- a/atuin-client/src/history.rs +++ b/atuin-client/src/history.rs @@ -19,6 +19,21 @@ pub struct History { pub deleted_at: Option>, } +// Forgive me, for I have sinned +// I need to replace rmp with something that is more backwards-compatible. +// Protobuf, or maybe just json +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, sqlx::FromRow)] +pub struct HistoryWithoutDelete { + pub id: String, + pub timestamp: chrono::DateTime, + pub duration: i64, + pub exit: i64, + pub command: String, + pub cwd: String, + pub session: String, + pub hostname: String, +} + impl History { #[allow(clippy::too_many_arguments)] pub fn new(