mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
Change argument type of write_asc_to_file from const char * to &Path
This commit is contained in:
@@ -1093,7 +1093,7 @@ unsafe fn export_key_to_asc_file(
|
||||
}
|
||||
info!(context, "Exporting key {}", as_str(file_name),);
|
||||
dc_delete_file(context, as_path(file_name));
|
||||
if !key.write_asc_to_file(file_name, context) {
|
||||
if !key.write_asc_to_file(as_path(file_name), context) {
|
||||
error!(context, "Cannot write key to {}", as_str(file_name),);
|
||||
} else {
|
||||
context.call_cb(
|
||||
|
||||
11
src/key.rs
11
src/key.rs
@@ -1,6 +1,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::io::Cursor;
|
||||
use std::path::Path;
|
||||
|
||||
use libc;
|
||||
use pgp::composed::{Deserializable, SignedPublicKey, SignedSecretKey};
|
||||
@@ -216,17 +217,13 @@ impl Key {
|
||||
.expect("failed to serialize key")
|
||||
}
|
||||
|
||||
pub fn write_asc_to_file(&self, file: *const libc::c_char, context: &Context) -> bool {
|
||||
if file.is_null() {
|
||||
return false;
|
||||
}
|
||||
|
||||
pub fn write_asc_to_file(&self, file: impl AsRef<Path>, context: &Context) -> bool {
|
||||
let file_content = self.to_asc(None).into_bytes();
|
||||
|
||||
if dc_write_file_safe(context, as_path(file), &file_content) {
|
||||
if dc_write_file_safe(context, &file, &file_content) {
|
||||
return true;
|
||||
} else {
|
||||
error!(context, "Cannot write key to {}", as_str(file));
|
||||
error!(context, "Cannot write key to {}", file.as_ref().display());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user