mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +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> {
|
pub async fn prune() -> Result<(), Error> {
|
||||||
let sql = include_str!("prune.sql");
|
|
||||||
task::spawn_blocking(move || {
|
task::spawn_blocking(move || {
|
||||||
let maybe_db = GLOBALS.db.blocking_lock();
|
let maybe_db = GLOBALS.db.blocking_lock();
|
||||||
let db = maybe_db.as_ref().unwrap();
|
let db = maybe_db.as_ref().unwrap();
|
||||||
let mut stmt = db.prepare(sql)?;
|
db.execute_batch(include_str!("prune.sql"))?;
|
||||||
stmt.execute(())?;
|
|
||||||
Ok::<(), Error>(())
|
Ok::<(), Error>(())
|
||||||
})
|
})
|
||||||
.await??;
|
.await??;
|
||||||
|
@ -178,8 +178,10 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
|||||||
ui.add_space(12.0);
|
ui.add_space(12.0);
|
||||||
|
|
||||||
if ui.button("Prune Database")
|
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() {
|
.clicked() {
|
||||||
|
*GLOBALS.status_message.blocking_write() = "Pruning database, please wait (this takes a long time)...".to_owned();
|
||||||
|
|
||||||
let _ = GLOBALS.to_overlord.send(ToOverlordMessage::PruneDatabase);
|
let _ = GLOBALS.to_overlord.send(ToOverlordMessage::PruneDatabase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user