mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
fetch_single_msg: do not ignore dc_receive_imf errors
If error is ignored, the message will never be fetched again, even if there was a database write error. dc_receive_imf itself is modified to ignore unrecoverable errors, to prevent endless refetching of incorrect messages.
This commit is contained in:
committed by
link2xt
parent
3cbd647dad
commit
6543c7c26f
@@ -32,6 +32,10 @@ enum CreateEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Receive a message and add it to the database.
|
/// Receive a message and add it to the database.
|
||||||
|
///
|
||||||
|
/// Returns an error on recoverable errors, e.g. database errors. In this case,
|
||||||
|
/// message parsing should be retried later. If message itself is wrong, logs
|
||||||
|
/// the error and returns success.
|
||||||
pub fn dc_receive_imf(
|
pub fn dc_receive_imf(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
imf_raw: &[u8],
|
imf_raw: &[u8],
|
||||||
@@ -55,10 +59,19 @@ pub fn dc_receive_imf(
|
|||||||
println!("{}", String::from_utf8_lossy(imf_raw));
|
println!("{}", String::from_utf8_lossy(imf_raw));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut mime_parser = MimeMessage::from_bytes(context, imf_raw)?;
|
let mut mime_parser = match MimeMessage::from_bytes(context, imf_raw) {
|
||||||
|
Err(err) => {
|
||||||
|
warn!(context, "dc_receive_imf: can't parse MIME: {}", err);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
Ok(mime_parser) => mime_parser,
|
||||||
|
};
|
||||||
|
|
||||||
// we can not add even an empty record if we have no info whatsoever
|
// we can not add even an empty record if we have no info whatsoever
|
||||||
ensure!(mime_parser.has_headers(), "No Headers Found");
|
if !mime_parser.has_headers() {
|
||||||
|
warn!(context, "dc_receive_imf: no headers found");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
// the function returns the number of created messages in the database
|
// the function returns the number of created messages in the database
|
||||||
let mut chat_id = ChatId::new(0);
|
let mut chat_id = ChatId::new(0);
|
||||||
@@ -305,7 +318,8 @@ fn add_parts(
|
|||||||
message::update_server_uid(context, &rfc724_mid, server_folder.as_ref(), server_uid);
|
message::update_server_uid(context, &rfc724_mid, server_folder.as_ref(), server_uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
bail!("Message already in DB");
|
warn!(context, "Message already in DB");
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut msgrmsg = if mime_parser.has_chat_version() {
|
let mut msgrmsg = if mime_parser.has_chat_version() {
|
||||||
@@ -369,7 +383,8 @@ fn add_parts(
|
|||||||
*hidden = true;
|
*hidden = true;
|
||||||
context.bob.write().unwrap().status = 0; // secure-join failed
|
context.bob.write().unwrap().status = 0; // secure-join failed
|
||||||
context.stop_ongoing();
|
context.stop_ongoing();
|
||||||
error!(context, "Error in Secure-Join message handling: {}", err);
|
warn!(context, "Error in Secure-Join message handling: {}", err);
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -496,7 +511,8 @@ fn add_parts(
|
|||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
*hidden = true;
|
*hidden = true;
|
||||||
error!(context, "Error in Secure-Join watching: {}", err);
|
warn!(context, "Error in Secure-Join watching: {}", err);
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -733,13 +733,7 @@ impl Imap {
|
|||||||
if let Err(err) =
|
if let Err(err) =
|
||||||
dc_receive_imf(context, &body, folder.as_ref(), server_uid, is_seen)
|
dc_receive_imf(context, &body, folder.as_ref(), server_uid, is_seen)
|
||||||
{
|
{
|
||||||
warn!(
|
return Err(Error::Other(format!("dc_receive_imf error: {}", err)));
|
||||||
context,
|
|
||||||
"dc_receive_imf failed for imap-message {}/{}: {:?}",
|
|
||||||
folder.as_ref(),
|
|
||||||
server_uid,
|
|
||||||
err
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user