From 36700a0a8761990e01735ba88fb88706db43494b Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 15 Sep 2020 11:15:01 +0200 Subject: [PATCH] api2/pull: make pull worker abortable by selecting between the pull_future and the abort future Signed-off-by: Dominik Csapak --- src/api2/pull.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api2/pull.rs b/src/api2/pull.rs index fc13cf40..09e27a17 100644 --- a/src/api2/pull.rs +++ b/src/api2/pull.rs @@ -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));