better bubble up DB errors and guard one unwrap() where a crash occured during integration test run

(and possibly also related to #633)
This commit is contained in:
holger krekel
2019-09-28 12:48:41 +02:00
parent a5cde0d137
commit feee340f4d
2 changed files with 7 additions and 11 deletions

View File

@@ -610,7 +610,7 @@ unsafe fn add_parts(
let icnt = mime_parser.parts.len();
let mut txt_raw = None;
let is_ok = context
context
.sql
.prepare(
"INSERT INTO msgs \
@@ -697,13 +697,10 @@ unsafe fn add_parts(
Ok(())
},
)
.is_ok();
if !is_ok {
// i/o error - there is nothing more we can do - in other cases, we try to write at least an empty record
cleanup(mime_in_reply_to, mime_references);
bail!("Cannot write DB.");
}
.map_err(|err| {
cleanup(mime_in_reply_to, mime_references);
err
})?;
info!(
context,

View File

@@ -1,7 +1,6 @@
//! End-to-end encryption support.
use std::collections::HashSet;
use std::ffi::CStr;
use std::ptr;
use std::str::FromStr;
@@ -479,8 +478,8 @@ fn update_gossip_peerstates(
if !optional_field.fld_name.is_null()
&& as_str(optional_field.fld_name) == "Autocrypt-Gossip"
{
let value = unsafe { CStr::from_ptr(optional_field.fld_value).to_str().unwrap() };
let gossip_header = Aheader::from_str(value);
let value = to_string_lossy(optional_field.fld_value);
let gossip_header = Aheader::from_str(&value);
if let Ok(ref header) = gossip_header {
if recipients.is_none() {