src/backup/manifest.rs: add verify_file

This commit is contained in:
Dietmar Maurer
2019-10-13 10:09:12 +02:00
parent 511a47bd73
commit f06b820ac0
3 changed files with 55 additions and 67 deletions

View File

@ -121,13 +121,16 @@ impl BackupReader {
}
/// Download backup manifest (index.json)
pub async fn download_manifest(&self) -> Result<Value, Error> {
pub async fn download_manifest(&self) -> Result<BackupManifest, Error> {
use std::convert::TryFrom;
let raw_data = self.download(MANIFEST_BLOB_NAME, Vec::with_capacity(64*1024)).await?;
let blob = DataBlob::from_raw(raw_data)?;
blob.verify_crc()?;
let data = blob.decode(self.crypt_config.as_ref().map(Arc::as_ref))?;
let result: Value = serde_json::from_slice(&data[..])?;
Ok(result)
let json: Value = serde_json::from_slice(&data[..])?;
BackupManifest::try_from(json)
}
}