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 /src/command/client/search.rs | |
| 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 '')
| -rw-r--r-- | src/command/client/search.rs | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/command/client/search.rs b/src/command/client/search.rs index dd6fcb32..50dfec10 100644 --- a/src/command/client/search.rs +++ b/src/command/client/search.rs @@ -102,14 +102,15 @@ impl Cmd { eprintln!("{item}"); } else { let list_mode = ListMode::from_flags(self.human, self.cmd_only); - let entries = run_non_interactive( + + let mut entries = run_non_interactive( settings, - self.cwd, + self.cwd.clone(), self.exit, self.exclude_exit, - self.exclude_cwd, - self.before, - self.after, + self.exclude_cwd.clone(), + self.before.clone(), + self.after.clone(), self.limit, &self.query, db, @@ -125,8 +126,25 @@ impl Cmd { // delete it // it only took me _years_ to add this // sorry - for entry in entries { - db.delete(entry).await?; + while !entries.is_empty() { + for entry in &entries { + eprintln!("deleting {}", entry.id); + db.delete(entry.clone()).await?; + } + + entries = run_non_interactive( + settings, + self.cwd.clone(), + self.exit, + self.exclude_exit, + self.exclude_cwd.clone(), + self.before.clone(), + self.after.clone(), + self.limit, + &self.query, + db, + ) + .await?; } } else { super::history::print_list(&entries, list_mode, self.format.as_deref()); |
