aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-client
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2023-03-24 09:04:57 +0000
committerGitHub <noreply@github.com>2023-03-24 09:04:57 +0000
commit79622cf698a1c831341f6e3906005ddbb54c55d8 (patch)
tree275a44d7d719bedfd8ecd43e7dec40a6e93fb2ed /atuin-client
parentBump debian from bullseye-20230227-slim to bullseye-20230320-slim (#802) (diff)
downloadatuin-79622cf698a1c831341f6e3906005ddbb54c55d8.zip
Delete all instances of a command (#797)
* Delete all instances of a command Our search command will de-dupe results by default. But... This isn't great for deleting! You don't want to run it over-and-over-and-over until all commands are deleted. Loop the query, and keep on deleting what it returns until they are all gone. * Optimize delete upload It was running a request for every element, on every sync lol Only push a delete if needed Future: push all deletes in one request
Diffstat (limited to 'atuin-client')
-rw-r--r--atuin-client/src/database.rs1
-rw-r--r--atuin-client/src/sync.rs7
2 files changed, 8 insertions, 0 deletions
diff --git a/atuin-client/src/database.rs b/atuin-client/src/database.rs
index 4135646c..bb4d9dfa 100644
--- a/atuin-client/src/database.rs
+++ b/atuin-client/src/database.rs
@@ -460,6 +460,7 @@ impl Database for Sqlite {
])
.group_by("command")
.group_by("exit")
+ .and_where("deleted_at is null")
.order_desc("timestamp");
let query = query.sql().expect("bug in list query. please report");
diff --git a/atuin-client/src/sync.rs b/atuin-client/src/sync.rs
index 1c0acaf8..474084d7 100644
--- a/atuin-client/src/sync.rs
+++ b/atuin-client/src/sync.rs
@@ -111,6 +111,9 @@ async fn sync_upload(
) -> Result<()> {
debug!("starting sync upload");
+ let remote_status = client.status().await?;
+ let remote_deleted: HashSet<String> = HashSet::from_iter(remote_status.deleted.clone());
+
let initial_remote_count = client.count().await?;
let mut remote_count = initial_remote_count;
@@ -157,6 +160,10 @@ async fn sync_upload(
let deleted = db.deleted().await?;
for i in deleted {
+ if remote_deleted.contains(&i.id) {
+ continue;
+ }
+
info!("deleting {} on remote", i.id);
client.delete_history(i).await?;
}