From 374255dd5856465b30d4c90d5882b150fa6c47de Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Fri, 2 Feb 2024 15:18:50 +0000 Subject: 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. --- atuin-client/src/record/sqlite_store.rs | 6 ++++++ atuin-client/src/record/store.rs | 2 ++ 2 files changed, 8 insertions(+) (limited to 'atuin-client/src/record') 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>> { 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>; + async fn delete(&self, id: RecordId) -> Result<()>; + async fn delete_all(&self) -> Result<()>; async fn len(&self, host: HostId, tag: &str) -> Result; async fn len_tag(&self, tag: &str) -> Result; -- cgit v1.3.1