diff options
| author | Ellie Huxtable <ellie@elliehuxtable.com> | 2023-03-24 09:04:57 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-24 09:04:57 +0000 |
| commit | 79622cf698a1c831341f6e3906005ddbb54c55d8 (patch) | |
| tree | 275a44d7d719bedfd8ecd43e7dec40a6e93fb2ed /atuin-client/src | |
| parent | Bump debian from bullseye-20230227-slim to bullseye-20230320-slim (#802) (diff) | |
| download | atuin-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/src')
| -rw-r--r-- | atuin-client/src/database.rs | 1 | ||||
| -rw-r--r-- | atuin-client/src/sync.rs | 7 |
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?; } |
