aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-client/src/encryption.rs
diff options
context:
space:
mode:
Diffstat (limited to 'atuin-client/src/encryption.rs')
-rw-r--r--atuin-client/src/encryption.rs23
1 files changed, 21 insertions, 2 deletions
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)
}