mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
Use safe version of dc_write_file
* src/key.rs(write_asc_to_file): simplify code using safe version of dc_write_file() function
This commit is contained in:
23
src/key.rs
23
src/key.rs
@@ -223,25 +223,14 @@ impl Key {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let file_content = self.to_asc(None);
|
let file_content = self.to_asc(None).into_bytes();
|
||||||
let file_content_c = CString::new(file_content).unwrap();
|
|
||||||
|
|
||||||
let success = if 0
|
if dc_write_file_safe(context, as_path(file), &file_content) {
|
||||||
== unsafe {
|
return true;
|
||||||
dc_write_file(
|
|
||||||
context,
|
|
||||||
file,
|
|
||||||
file_content_c.as_ptr() as *const libc::c_void,
|
|
||||||
file_content_c.as_bytes().len(),
|
|
||||||
)
|
|
||||||
} {
|
|
||||||
error!(context, "Cannot write key to {}", to_string(file));
|
|
||||||
false
|
|
||||||
} else {
|
} else {
|
||||||
true
|
error!(context, "Cannot write key to {}", as_str(file));
|
||||||
};
|
return false;
|
||||||
|
}
|
||||||
success
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fingerprint(&self) -> String {
|
pub fn fingerprint(&self) -> String {
|
||||||
|
|||||||
Reference in New Issue
Block a user