diff --git a/src/restore.rs b/src/restore.rs index aec8f8e..28f6548 100644 --- a/src/restore.rs +++ b/src/restore.rs @@ -5,6 +5,7 @@ use std::convert::TryInto; use anyhow::{format_err, bail, Error}; use once_cell::sync::OnceCell; +use tokio::runtime::Runtime; use proxmox_backup::tools::runtime::{get_runtime, block_in_place}; use proxmox_backup::backup::*; @@ -22,7 +23,7 @@ pub struct ImageAccessInfo { pub(crate) struct ProxmoxRestore { setup: BackupSetup, - runtime: Arc, + runtime: Arc, pub crypt_config: Option>, pub client: OnceCell>, chunk_reader: OnceCell, @@ -32,11 +33,11 @@ pub(crate) struct ProxmoxRestore { impl ProxmoxRestore { - pub fn new(setup: BackupSetup) -> Result { - - // keep a reference to the runtime - else the runtime can be dropped - // and further connections fails. - let runtime = get_runtime(); + /// Create a new instance, using the specified Runtime + /// + /// We keep a reference to the runtime - else the runtime can be + /// dropped and further connections fails. + pub fn with_runtime(setup: BackupSetup, runtime: Arc) -> Result { let crypt_config = match setup.keyfile { None => None, @@ -62,6 +63,11 @@ impl ProxmoxRestore { }) } + pub fn new(setup: BackupSetup) -> Result { + let runtime = get_runtime(); + Self::with_runtime(setup, runtime) + } + pub async fn connect(&self) -> Result { let options = HttpClientOptions::new()