Resultify dc_write_file and related functions

This commit is contained in:
Alexander Krotov
2019-11-30 00:11:21 +01:00
committed by holger krekel
parent 4e6d0c9c69
commit 02e281e465
3 changed files with 32 additions and 28 deletions

View File

@@ -217,15 +217,18 @@ impl Key {
.expect("failed to serialize key")
}
pub fn write_asc_to_file(&self, file: impl AsRef<Path>, context: &Context) -> bool {
pub fn write_asc_to_file(
&self,
file: impl AsRef<Path>,
context: &Context,
) -> std::io::Result<()> {
let file_content = self.to_asc(None).into_bytes();
if dc_write_file(context, &file, &file_content) {
true
} else {
let res = dc_write_file(context, &file, &file_content);
if res.is_err() {
error!(context, "Cannot write key to {}", file.as_ref().display());
false
}
res
}
pub fn fingerprint(&self) -> String {