From fabeaf9cf1a4fc620d3493c87e2e7078046a294c Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 29 Jun 2020 09:34:18 +0200 Subject: [PATCH] proxmox_backup_connect: return info about previous backup --- src/lib.rs | 10 ++++++++++ src/worker_task.rs | 8 ++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 53de21c..f77f66f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -204,6 +204,11 @@ pub extern "C" fn proxmox_backup_new( } /// Open connection to the backup server (sync) +/// +/// Returns: +/// 0 ... Sucecss (no prevbious backup) +/// 1 ... Success (found previous backup) +/// -1 ... Error #[no_mangle] #[allow(clippy::not_unsafe_ptr_arg_deref)] pub extern "C" fn proxmox_backup_connect( @@ -234,6 +239,11 @@ pub extern "C" fn proxmox_backup_connect( } /// Open connection to the backup server +/// +/// Returns: +/// 0 ... Sucecss (no prevbious backup) +/// 1 ... Success (found previous backup) +/// -1 ... Error #[no_mangle] #[allow(clippy::not_unsafe_ptr_arg_deref)] pub extern "C" fn proxmox_backup_connect_async( diff --git a/src/worker_task.rs b/src/worker_task.rs index 33edc70..13000b7 100644 --- a/src/worker_task.rs +++ b/src/worker_task.rs @@ -159,14 +159,18 @@ fn backup_worker_task( let last_manifest = writer.download_previous_manifest().await; let mut manifest_guard = manifest.lock().unwrap(); + let mut result = 0; *manifest_guard = match last_manifest { - Ok(last_manifest) => Some(Arc::new(last_manifest)), + Ok(last_manifest) => { + result = 1; + Some(Arc::new(last_manifest)) + }, Err(_) => None }; let mut client_guard = client.lock().unwrap(); *client_guard = Some(writer); - Ok(0) + Ok(result) }; tokio::spawn(handle_async_command(command_future, abort.listen(), callback_info)); -- 2.39.5