mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-08-06 19:15:00 +00:00
api: wrap set_protection in spawn_blocking
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
7beb27d428
commit
67d7a59d68
@ -2097,7 +2097,7 @@ pub fn get_protection(
|
|||||||
},
|
},
|
||||||
)]
|
)]
|
||||||
/// En- or disable protection for a specific backup
|
/// En- or disable protection for a specific backup
|
||||||
pub fn set_protection(
|
pub async fn set_protection(
|
||||||
store: String,
|
store: String,
|
||||||
ns: Option<BackupNamespace>,
|
ns: Option<BackupNamespace>,
|
||||||
backup_dir: pbs_api_types::BackupDir,
|
backup_dir: pbs_api_types::BackupDir,
|
||||||
@ -2105,20 +2105,24 @@ pub fn set_protection(
|
|||||||
rpcenv: &mut dyn RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
|
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
|
||||||
let ns = ns.unwrap_or_default();
|
|
||||||
let datastore = check_privs_and_load_store(
|
|
||||||
&store,
|
|
||||||
&ns,
|
|
||||||
&auth_id,
|
|
||||||
PRIV_DATASTORE_MODIFY,
|
|
||||||
PRIV_DATASTORE_BACKUP,
|
|
||||||
Some(Operation::Write),
|
|
||||||
&backup_dir.group,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let backup_dir = datastore.backup_dir(ns, backup_dir)?;
|
tokio::task::spawn_blocking(move || {
|
||||||
|
let ns = ns.unwrap_or_default();
|
||||||
|
let datastore = check_privs_and_load_store(
|
||||||
|
&store,
|
||||||
|
&ns,
|
||||||
|
&auth_id,
|
||||||
|
PRIV_DATASTORE_MODIFY,
|
||||||
|
PRIV_DATASTORE_BACKUP,
|
||||||
|
Some(Operation::Write),
|
||||||
|
&backup_dir.group,
|
||||||
|
)?;
|
||||||
|
|
||||||
datastore.update_protection(&backup_dir, protected)
|
let backup_dir = datastore.backup_dir(ns, backup_dir)?;
|
||||||
|
|
||||||
|
datastore.update_protection(&backup_dir, protected)
|
||||||
|
})
|
||||||
|
.await?
|
||||||
}
|
}
|
||||||
|
|
||||||
#[api(
|
#[api(
|
||||||
|
Loading…
Reference in New Issue
Block a user