Skip to content

Pause I/O in get_backup() #4177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/imex/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,21 +373,20 @@ pub async fn get_backup(context: &Context, qr: Qr) -> Result<()> {
!context.is_configured().await?,
"Cannot import backups to accounts in use."
);
ensure!(
!context.scheduler.is_running().await,
"cannot import backup, IO is running"
);
let mut guard = context.scheduler.pause(context).await;

// Acquire global "ongoing" mutex.
let cancel_token = context.alloc_ongoing().await?;
tokio::select! {
let res = tokio::select! {
biased;
res = get_backup_inner(context, qr) => {
context.free_ongoing().await;
res
}
_ = cancel_token.recv() => Err(format_err!("cancelled")),
}
};
guard.resume().await;
res
}

async fn get_backup_inner(context: &Context, qr: Qr) -> Result<()> {
Expand Down