summaryrefslogtreecommitdiffstats
path: root/atuin-client
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2024-01-22 16:48:21 +0000
committerGitHub <noreply@github.com>2024-01-22 16:48:21 +0000
commit600ebc33ab46d8f461c78b5a4a8e8bc81714d211 (patch)
tree0839bab1729de29816d59232522b82d738910ff2 /atuin-client
parentf727d6c8bf34482d11948b114249f2e1523c81ed (diff)
feat: make store init idempotent (#1609)
Diffstat (limited to 'atuin-client')
-rw-r--r--atuin-client/src/history/store.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/atuin-client/src/history/store.rs b/atuin-client/src/history/store.rs
index ab88182a1..73166de14 100644
--- a/atuin-client/src/history/store.rs
+++ b/atuin-client/src/history/store.rs
@@ -1,3 +1,5 @@
+use std::collections::HashSet;
+
use eyre::{bail, eyre, Result};
use rmp::decode::Bytes;
@@ -230,6 +232,20 @@ impl HistoryStore {
Ok(())
}
+
+ /// Get a list of history IDs that exist in the store
+ /// Note: This currently involves loading all history into memory. This is not going to be a
+ /// large amount in absolute terms, but do not all it in a hot loop.
+ pub async fn history_ids(&self) -> Result<HashSet<HistoryId>> {
+ let history = self.history().await?;
+
+ let ret = HashSet::from_iter(history.iter().map(|h| match h {
+ HistoryRecord::Create(h) => h.id.clone(),
+ HistoryRecord::Delete(id) => id.clone(),
+ }));
+
+ Ok(ret)
+ }
}
#[cfg(test)]