Fix pruning of the database

This commit is contained in:
Mike Dilger 2023-01-18 10:45:57 +13:00
parent 5a4dfdbc22
commit fd216781a3
2 changed files with 4 additions and 4 deletions

View File

@ -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??;

View File

@ -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);
}