]> git.proxmox.com Git - proxmox-backup.git/commitdiff
api2/pull: make pull worker abortable
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 15 Sep 2020 09:15:01 +0000 (11:15 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 17 Sep 2020 04:11:33 +0000 (06:11 +0200)
by selecting between the pull_future and the abort future

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/api2/pull.rs

index fc13cf40c0c5ac8143ebbe8bf4c80321a0cc37ce..09e27a177465c85042f4597b156aab9c0500af9e 100644 (file)
@@ -176,7 +176,13 @@ async fn pull (
 
         worker.log(format!("sync datastore '{}' start", store));
 
-        pull_store(&worker, &client, &src_repo, tgt_store.clone(), delete, userid).await?;
+        let pull_future = pull_store(&worker, &client, &src_repo, tgt_store.clone(), delete, userid);
+        let future = select!{
+            success = pull_future.fuse() => success,
+            abort = worker.abort_future().map(|_| Err(format_err!("pull aborted"))) => abort,
+        };
+
+        let _ = future?;
 
         worker.log(format!("sync datastore '{}' end", store));