mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 11:43:43 +00:00
Fix pruning of the database
This commit is contained in:
parent
5a4dfdbc22
commit
fd216781a3
@ -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??;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user