Skip to content

Commit

Permalink
Merge pull request #1864 from get10101/fix/timeout-close-position-tra…
Browse files Browse the repository at this point in the history
…de-dialog

fix: Run all of the db backup in a dedicated thread
  • Loading branch information
holzeis authored Jan 22, 2024
2 parents f0e9d3c + 2691a48 commit c394dc6
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 c394dc6

Please sign in to comment.