mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-08-14 09:25:46 +00:00
api: wrap delete_group in spawn_blocking
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
a577d7d801
commit
6f67dc1197
@ -273,31 +273,34 @@ pub fn list_groups(
|
|||||||
},
|
},
|
||||||
)]
|
)]
|
||||||
/// Delete backup group including all snapshots.
|
/// Delete backup group including all snapshots.
|
||||||
pub fn delete_group(
|
pub async fn delete_group(
|
||||||
store: String,
|
store: String,
|
||||||
ns: Option<BackupNamespace>,
|
ns: Option<BackupNamespace>,
|
||||||
group: pbs_api_types::BackupGroup,
|
group: pbs_api_types::BackupGroup,
|
||||||
_info: &ApiMethod,
|
|
||||||
rpcenv: &mut dyn RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, 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(
|
tokio::task::spawn_blocking(move || {
|
||||||
&store,
|
let ns = ns.unwrap_or_default();
|
||||||
&ns,
|
|
||||||
&auth_id,
|
|
||||||
PRIV_DATASTORE_MODIFY,
|
|
||||||
PRIV_DATASTORE_PRUNE,
|
|
||||||
Some(Operation::Write),
|
|
||||||
&group,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
if !datastore.remove_backup_group(&ns, &group)? {
|
let datastore = check_privs_and_load_store(
|
||||||
bail!("group only partially deleted due to protected snapshots");
|
&store,
|
||||||
}
|
&ns,
|
||||||
|
&auth_id,
|
||||||
|
PRIV_DATASTORE_MODIFY,
|
||||||
|
PRIV_DATASTORE_PRUNE,
|
||||||
|
Some(Operation::Write),
|
||||||
|
&group,
|
||||||
|
)?;
|
||||||
|
|
||||||
Ok(Value::Null)
|
if !datastore.remove_backup_group(&ns, &group)? {
|
||||||
|
bail!("group only partially deleted due to protected snapshots");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Value::Null)
|
||||||
|
})
|
||||||
|
.await?
|
||||||
}
|
}
|
||||||
|
|
||||||
#[api(
|
#[api(
|
||||||
|
Loading…
Reference in New Issue
Block a user