src/api2/config: correctly lock files

This commit is contained in:
Dietmar Maurer
2020-01-15 11:57:12 +01:00
parent 1c79e1017f
commit 347834df25
4 changed files with 10 additions and 6 deletions

View File

@ -53,7 +53,7 @@ pub fn list_datastores(
/// Create new datastore config.
pub fn create_datastore(name: String, param: Value) -> Result<(), Error> {
// fixme: locking ?
let _lock = crate::tools::open_file_locked(datastore::DATASTORE_CFG_LOCKFILE, std::time::Duration::new(10, 0))?;
let datastore: datastore::DataStoreConfig = serde_json::from_value(param.clone())?;
@ -122,7 +122,8 @@ pub fn update_datastore(
path: Option<String>,
) -> Result<(), Error> {
// fixme: locking ?
let _lock = crate::tools::open_file_locked(datastore::DATASTORE_CFG_LOCKFILE, std::time::Duration::new(10, 0))?;
// pass/compare digest
let (mut config, _digest) = datastore::config()?;

View File

@ -56,7 +56,7 @@ pub fn list_remotes(
/// Create new remote.
pub fn create_remote(name: String, param: Value) -> Result<(), Error> {
// fixme: locking ?
let _lock = crate::tools::open_file_locked(remotes::REMOTES_CFG_LOCKFILE, std::time::Duration::new(10, 0))?;
let remote: remotes::Remote = serde_json::from_value(param.clone())?;
@ -130,7 +130,8 @@ pub fn update_remote(
password: Option<String>,
) -> Result<(), Error> {
// fixme: locking ?
let _lock = crate::tools::open_file_locked(remotes::REMOTES_CFG_LOCKFILE, std::time::Duration::new(10, 0))?;
// pass/compare digest
let (mut config, _digest) = remotes::config()?;