datastore: remove load_manifest_json

There's no point in having that as a seperate method, just parse the
thing into a struct and write it back out correctly.

Also makes further changes to the method simpler.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
Stefan Reiter
2020-10-14 14:16:35 +02:00
committed by Dietmar Maurer
parent bfa54f2e85
commit 883aa6d5a4
4 changed files with 9 additions and 20 deletions

View File

@ -1428,9 +1428,9 @@ fn get_notes(
let allowed = (user_privs & PRIV_DATASTORE_READ) != 0;
if !allowed { check_backup_owner(&datastore, backup_dir.group(), &userid)?; }
let manifest = datastore.load_manifest_json(&backup_dir)?;
let (manifest, _) = datastore.load_manifest(&backup_dir)?;
let notes = manifest["unprotected"]["notes"]
let notes = manifest.unprotected["notes"]
.as_str()
.unwrap_or("");
@ -1481,9 +1481,9 @@ fn set_notes(
let allowed = (user_privs & PRIV_DATASTORE_READ) != 0;
if !allowed { check_backup_owner(&datastore, backup_dir.group(), &userid)?; }
let mut manifest = datastore.load_manifest_json(&backup_dir)?;
let (mut manifest, _) = datastore.load_manifest(&backup_dir)?;
manifest["unprotected"]["notes"] = notes.into();
manifest.unprotected["notes"] = notes.into();
datastore.store_manifest(&backup_dir, manifest)?;