Skip to content

Commit

Permalink
fix: Run all of the db backup in a dedicated thread
Browse files Browse the repository at this point in the history
Without that fix the open and close position protocol was affected by the db backup to finish. That could lead to the trade dialog not showing a success message.
  • Loading branch information
holzeis committed Jan 22, 2024
1 parent f0e9d3c commit 46cd24d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions mobile/native/src/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use std::fs;
use std::path::Path;
use std::sync::Arc;
use std::time::Duration;
use tokio::task::spawn_blocking;

const BLACKLIST: [&str; 1] = ["ln/network_graph"];

Expand All @@ -40,15 +39,18 @@ impl DBBackupSubscriber {
}

pub fn back_up(&self) -> Result<()> {
let db_backup = db::back_up()?;
tracing::debug!("Successfully created backup of database! Uploading snapshot!");
let value = fs::read(db_backup)?;
spawn_blocking({
let runtime = crate::state::get_or_create_tokio_runtime()?;
runtime.spawn_blocking({
let client = self.client.clone();
move || {
let db_backup = db::back_up()?;
tracing::debug!("Successfully created backup of database! Uploading snapshot!");
let value = fs::read(db_backup)?;
client
.backup(format!("{DB_BACKUP_KEY}/{DB_BACKUP_NAME}"), value)
.forget()
.forget();

anyhow::Ok(())
}
});

Expand Down

0 comments on commit 46cd24d

Please sign in to comment.