api2/config/remote: lock and use digest for removal
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
4f966d0592
commit
99f443c6ae
@ -251,6 +251,10 @@ pub fn update_remote(
|
|||||||
name: {
|
name: {
|
||||||
schema: REMOTE_ID_SCHEMA,
|
schema: REMOTE_ID_SCHEMA,
|
||||||
},
|
},
|
||||||
|
digest: {
|
||||||
|
optional: true,
|
||||||
|
schema: PROXMOX_CONFIG_DIGEST_SCHEMA,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
access: {
|
access: {
|
||||||
@ -258,12 +262,16 @@ pub fn update_remote(
|
|||||||
},
|
},
|
||||||
)]
|
)]
|
||||||
/// Remove a remote from the configuration file.
|
/// Remove a remote from the configuration file.
|
||||||
pub fn delete_remote(name: String) -> Result<(), Error> {
|
pub fn delete_remote(name: String, digest: Option<String>) -> Result<(), Error> {
|
||||||
|
|
||||||
// fixme: locking ?
|
let _lock = crate::tools::open_file_locked(remote::REMOTE_CFG_LOCKFILE, std::time::Duration::new(10, 0))?;
|
||||||
// fixme: check digest ?
|
|
||||||
|
|
||||||
let (mut config, _digest) = remote::config()?;
|
let (mut config, expected_digest) = remote::config()?;
|
||||||
|
|
||||||
|
if let Some(ref digest) = digest {
|
||||||
|
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||||
|
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||||
|
}
|
||||||
|
|
||||||
match config.sections.get(&name) {
|
match config.sections.get(&name) {
|
||||||
Some(_) => { config.sections.remove(&name); },
|
Some(_) => { config.sections.remove(&name); },
|
||||||
|
Loading…
Reference in New Issue
Block a user