diff --git a/src/db/mod.rs b/src/db/mod.rs index d5f59145..22ab19c5 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -124,12 +124,10 @@ fn upgrade(db: &Connection, mut version: u16) -> Result<(), Error> { } pub async fn prune() -> Result<(), Error> { - let sql = include_str!("prune.sql"); task::spawn_blocking(move || { let maybe_db = GLOBALS.db.blocking_lock(); let db = maybe_db.as_ref().unwrap(); - let mut stmt = db.prepare(sql)?; - stmt.execute(())?; + db.execute_batch(include_str!("prune.sql"))?; Ok::<(), Error>(()) }) .await??; diff --git a/src/ui/settings.rs b/src/ui/settings.rs index 6cc4bf12..fb670e1e 100644 --- a/src/ui/settings.rs +++ b/src/ui/settings.rs @@ -178,8 +178,10 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra ui.add_space(12.0); if ui.button("Prune Database") - .on_hover_text("This will delete overridden events, events older than a week, and related data while keeping everything important. It make make Gossip somewhat unresponsive until it is complete.") + .on_hover_text("This will delete overridden events, events older than a week, and related data while keeping everything important. It can take MANY MINUTES to complete, and when complete there will be a status message indicating so. Also, because the database will be very busy, best not to use gossip while pruning, just wait.") .clicked() { + *GLOBALS.status_message.blocking_write() = "Pruning database, please wait (this takes a long time)...".to_owned(); + let _ = GLOBALS.to_overlord.send(ToOverlordMessage::PruneDatabase); }