mirror of
https://github.com/chatmail/core.git
synced 2026-05-24 17:26:30 +03:00
Resultify dc_create_folder and don't ignore its errors
This commit is contained in:
@@ -381,11 +381,14 @@ pub(crate) fn dc_copy_file(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn dc_create_folder(context: &Context, path: impl AsRef<std::path::Path>) -> bool {
|
pub(crate) fn dc_create_folder(
|
||||||
|
context: &Context,
|
||||||
|
path: impl AsRef<std::path::Path>,
|
||||||
|
) -> Result<(), std::io::Error> {
|
||||||
let path_abs = dc_get_abs_path(context, &path);
|
let path_abs = dc_get_abs_path(context, &path);
|
||||||
if !path_abs.exists() {
|
if !path_abs.exists() {
|
||||||
match fs::create_dir_all(path_abs) {
|
match fs::create_dir_all(path_abs) {
|
||||||
Ok(_) => true,
|
Ok(_) => Ok(()),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(
|
||||||
context,
|
context,
|
||||||
@@ -393,11 +396,11 @@ pub(crate) fn dc_create_folder(context: &Context, path: impl AsRef<std::path::Pa
|
|||||||
path.as_ref().display(),
|
path.as_ref().display(),
|
||||||
err
|
err
|
||||||
);
|
);
|
||||||
false
|
Err(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
true
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -825,7 +828,7 @@ mod tests {
|
|||||||
|
|
||||||
assert!(dc_delete_file(context, "$BLOBDIR/foobar"));
|
assert!(dc_delete_file(context, "$BLOBDIR/foobar"));
|
||||||
assert!(dc_delete_file(context, "$BLOBDIR/dada"));
|
assert!(dc_delete_file(context, "$BLOBDIR/dada"));
|
||||||
assert!(dc_create_folder(context, "$BLOBDIR/foobar-folder"));
|
assert!(dc_create_folder(context, "$BLOBDIR/foobar-folder").is_ok());
|
||||||
assert!(dc_file_exist(context, "$BLOBDIR/foobar-folder",));
|
assert!(dc_file_exist(context, "$BLOBDIR/foobar-folder",));
|
||||||
assert!(!dc_delete_file(context, "$BLOBDIR/foobar-folder"));
|
assert!(!dc_delete_file(context, "$BLOBDIR/foobar-folder"));
|
||||||
|
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ pub fn JobImexImap(context: &Context, job: &Job) -> Result<()> {
|
|||||||
context.free_ongoing();
|
context.free_ongoing();
|
||||||
bail!("Cannot create private key or private key not available.");
|
bail!("Cannot create private key or private key not available.");
|
||||||
} else {
|
} else {
|
||||||
dc_create_folder(context, ¶m);
|
dc_create_folder(context, ¶m)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let path = Path::new(param);
|
let path = Path::new(param);
|
||||||
|
|||||||
Reference in New Issue
Block a user