From b64c945a2d686546b1b64049806f015095ba7697 Mon Sep 17 00:00:00 2001 From: Lina Butler Date: Fri, 14 Jul 2023 08:54:32 -0700 Subject: [PATCH] suggest: Support clearing the suggestions store. This commit exposes `SuggestDb.clear()` as `SuggestStore.clear()`, and ensures that it removes all icons in addition to suggestions and metadata. --- components/suggest/src/db.rs | 2 ++ components/suggest/src/store.rs | 5 +++++ components/suggest/src/suggest.udl | 3 +++ 3 files changed, 10 insertions(+) diff --git a/components/suggest/src/db.rs b/components/suggest/src/db.rs index bdf1395e68..b97850574d 100644 --- a/components/suggest/src/db.rs +++ b/components/suggest/src/db.rs @@ -212,9 +212,11 @@ impl SuggestDb { Ok(()) } + /// Clears the database, removing all suggestions, icons, and metadata. pub fn clear(&self) -> Result<()> { self.conn.lock().unwrap().execute_batch( "DELETE FROM suggestions; + DELETE FROM icons; DELETE FROM meta;", )?; Ok(()) diff --git a/components/suggest/src/store.rs b/components/suggest/src/store.rs index 89309b7a49..0182642a3b 100644 --- a/components/suggest/src/store.rs +++ b/components/suggest/src/store.rs @@ -202,6 +202,11 @@ impl SuggestStore { Ok(()) } + + pub fn clear(&self) -> Result<(), SuggestApiError> { + let writer = &self.dbs()?.writer; + Ok(writer.clear()?) + } } struct SuggestStoreDbs { diff --git a/components/suggest/src/suggest.udl b/components/suggest/src/suggest.udl index c0e5a9ee87..fc5bbd0f21 100644 --- a/components/suggest/src/suggest.udl +++ b/components/suggest/src/suggest.udl @@ -44,4 +44,7 @@ interface SuggestStore { [Throws=SuggestApiError] void ingest([ByRef] IngestLimits limits); + + [Throws=SuggestApiError] + void clear(); };