api2/pull: make pull worker abortable

by selecting between the pull_future and the abort future

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-09-15 11:15:01 +02:00 committed by Dietmar Maurer
parent dd4b42bac1
commit 36700a0a87
1 changed files with 7 additions and 1 deletions

View File

@ -176,7 +176,13 @@ async fn pull (
worker.log(format!("sync datastore '{}' start", store)); 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)); worker.log(format!("sync datastore '{}' end", store));