mirror of
https://github.com/chatmail/core.git
synced 2026-05-16 13:26:38 +03:00
more error logging with file operations in general
This commit is contained in:
@@ -420,8 +420,8 @@ pub(crate) fn dc_delete_file(context: &Context, path: impl AsRef<std::path::Path
|
|||||||
context.call_cb(Event::DeletedBlobFile(dpath));
|
context.call_cb(Event::DeletedBlobFile(dpath));
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Err(_err) => {
|
Err(err) => {
|
||||||
warn!(context, "Cannot delete \"{}\".", dpath);
|
warn!(context, "Cannot delete \"{}\": {}", dpath, err);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -442,7 +442,7 @@ pub(crate) fn dc_copy_file(
|
|||||||
"Cannot copy \"{}\" to \"{}\": {}",
|
"Cannot copy \"{}\" to \"{}\": {}",
|
||||||
src.as_ref().display(),
|
src.as_ref().display(),
|
||||||
dest.as_ref().display(),
|
dest.as_ref().display(),
|
||||||
err,
|
err
|
||||||
);
|
);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@@ -454,11 +454,12 @@ pub(crate) fn dc_create_folder(context: &Context, path: impl AsRef<std::path::Pa
|
|||||||
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(_) => true,
|
||||||
Err(_err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(
|
||||||
context,
|
context,
|
||||||
"Cannot create directory \"{}\".",
|
"Cannot create directory \"{}\": {}",
|
||||||
path.as_ref().display(),
|
path.as_ref().display(),
|
||||||
|
err
|
||||||
);
|
);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@@ -471,12 +472,13 @@ pub(crate) fn dc_create_folder(context: &Context, path: impl AsRef<std::path::Pa
|
|||||||
/// Write a the given content to provied file path.
|
/// Write a the given content to provied file path.
|
||||||
pub(crate) fn dc_write_file(context: &Context, path: impl AsRef<Path>, buf: &[u8]) -> bool {
|
pub(crate) fn dc_write_file(context: &Context, path: impl AsRef<Path>, buf: &[u8]) -> bool {
|
||||||
let path_abs = dc_get_abs_path(context, &path);
|
let path_abs = dc_get_abs_path(context, &path);
|
||||||
if let Err(_err) = fs::write(&path_abs, buf) {
|
if let Err(err) = fs::write(&path_abs, buf) {
|
||||||
warn!(
|
warn!(
|
||||||
context,
|
context,
|
||||||
"Cannot write {} bytes to \"{}\".",
|
"Cannot write {} bytes to \"{}\": {}",
|
||||||
buf.len(),
|
buf.len(),
|
||||||
path.as_ref().display(),
|
path.as_ref().display(),
|
||||||
|
err
|
||||||
);
|
);
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
@@ -495,8 +497,9 @@ pub fn dc_read_file<P: AsRef<std::path::Path>>(
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(
|
||||||
context,
|
context,
|
||||||
"Cannot read \"{}\" or file is empty.",
|
"Cannot read \"{}\" or file is empty: {}",
|
||||||
path.as_ref().display()
|
path.as_ref().display(),
|
||||||
|
err
|
||||||
);
|
);
|
||||||
Err(err.into())
|
Err(err.into())
|
||||||
}
|
}
|
||||||
@@ -514,8 +517,9 @@ pub fn dc_open_file<P: AsRef<std::path::Path>>(
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(
|
||||||
context,
|
context,
|
||||||
"Cannot read \"{}\" or file is empty.",
|
"Cannot read \"{}\" or file is empty: {}",
|
||||||
path.as_ref().display()
|
path.as_ref().display(),
|
||||||
|
err
|
||||||
);
|
);
|
||||||
Err(err.into())
|
Err(err.into())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user