src/backup/data_chunk.rs - decode: make crypt_config optional

This commit is contained in:
Dietmar Maurer 2019-06-13 11:44:38 +02:00
parent 046bcb9773
commit 51929e4532
1 changed files with 7 additions and 4 deletions

View File

@ -95,7 +95,7 @@ impl DataChunk {
}
/// Decode chunk data
pub fn decode(self, config: &CryptConfig) -> Result<Vec<u8>, Error> {
pub fn decode(self, config: Option<&CryptConfig>) -> Result<Vec<u8>, Error> {
let magic = self.magic();
@ -107,10 +107,13 @@ impl DataChunk {
return Ok(data);
} else if magic == &ENCR_COMPR_CHUNK_MAGIC_1_0 || magic == &ENCRYPTED_CHUNK_MAGIC_1_0 {
if let Some(config) = config {
let data = config.decode_chunk(&self.raw_data)?;
return Ok(data);
} else {
bail!("unable to decrypt chunk - missing CryptConfig");
}
} else {
bail!("Invalid chunk magic number.");
}