aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-client/src/record
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2024-02-02 15:18:50 +0000
committerEllie Huxtable <ellie@elliehuxtable.com>2024-02-02 18:01:09 +0000
commit374255dd5856465b30d4c90d5882b150fa6c47de (patch)
tree0c25941ba5250a898c58361573e71496c3761a86 /atuin-client/src/record
parentfeat: add `store push --force` (diff)
downloadatuin-374255dd5856465b30d4c90d5882b150fa6c47de.zip
feat: add `store pull`
This allows the user to 1. Specify that they want to sync, but ONLY pull new data 2. Specify that they wish to force pull, which will wipe the local store and download it from the remote With the other set of changes, this allows the user to perform sufficient maintenance to recovery from most errors I can think of right now.
Diffstat (limited to 'atuin-client/src/record')
-rw-r--r--atuin-client/src/record/sqlite_store.rs6
-rw-r--r--atuin-client/src/record/store.rs2
2 files changed, 8 insertions, 0 deletions
diff --git a/atuin-client/src/record/sqlite_store.rs b/atuin-client/src/record/sqlite_store.rs
index 4e4a3756..e5e3b9cd 100644
--- a/atuin-client/src/record/sqlite_store.rs
+++ b/atuin-client/src/record/sqlite_store.rs
@@ -154,6 +154,12 @@ impl Store for SqliteStore {
Ok(())
}
+ async fn delete_all(&self) -> Result<()> {
+ sqlx::query("delete from store").execute(&self.pool).await?;
+
+ Ok(())
+ }
+
async fn last(&self, host: HostId, tag: &str) -> Result<Option<Record<EncryptedData>>> {
let res =
sqlx::query("select * from store where host=?1 and tag=?2 order by idx desc limit 1")
diff --git a/atuin-client/src/record/store.rs b/atuin-client/src/record/store.rs
index 1d812549..ae8ea356 100644
--- a/atuin-client/src/record/store.rs
+++ b/atuin-client/src/record/store.rs
@@ -21,7 +21,9 @@ pub trait Store {
) -> Result<()>;
async fn get(&self, id: RecordId) -> Result<Record<EncryptedData>>;
+
async fn delete(&self, id: RecordId) -> Result<()>;
+ async fn delete_all(&self) -> Result<()>;
async fn len(&self, host: HostId, tag: &str) -> Result<u64>;
async fn len_tag(&self, tag: &str) -> Result<u64>;