src/api2/admin/datastore.rs - read_backup_index: add manifest with size

So that the client can display the size of the index file.
This commit is contained in:
Dietmar Maurer 2019-12-04 10:03:52 +01:00
parent ed858b0af4
commit 4f1e40a29e
1 changed files with 7 additions and 1 deletions

View File

@ -29,14 +29,20 @@ fn read_backup_index(store: &DataStore, backup_dir: &BackupDir) -> Result<Value,
let raw_data = file_get_contents(&path)?;
let data = DataBlob::from_raw(raw_data)?.decode(None)?;
let index_size = data.len();
let mut result: Value = serde_json::from_reader(&mut &data[..])?;
let result = result["files"].take();
let mut result = result["files"].take();
if result == Value::Null {
bail!("missing 'files' property in backup index {:?}", path);
}
result.as_array_mut().unwrap().push(json!({
"filename": "index.json.blob",
"size": index_size,
}));
Ok(result)
}