mirror of
https://github.com/chatmail/core.git
synced 2026-05-16 21:36:30 +03:00
Make add_or_lookup errors non-fatal in add_address_book()
This commit is contained in:
committed by
holger krekel
parent
4d1554c85b
commit
fbabe27fc1
@@ -497,9 +497,18 @@ impl Contact {
|
|||||||
|
|
||||||
for (name, addr) in split_address_book(addr_book.as_ref()).into_iter() {
|
for (name, addr) in split_address_book(addr_book.as_ref()).into_iter() {
|
||||||
let name = normalize_name(name);
|
let name = normalize_name(name);
|
||||||
let (_, modified) = Contact::add_or_lookup(context, name, addr, Origin::AdressBook)?;
|
match Contact::add_or_lookup(context, name, addr, Origin::AdressBook) {
|
||||||
if modified != Modifier::None {
|
Err(err) => {
|
||||||
modify_cnt += 1
|
warn!(
|
||||||
|
context,
|
||||||
|
"Failed to add address {} from address book: {}", addr, err
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Ok((_, modified)) => {
|
||||||
|
if modified != Modifier::None {
|
||||||
|
modify_cnt += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if modify_cnt > 0 {
|
if modify_cnt > 0 {
|
||||||
@@ -1229,6 +1238,7 @@ mod tests {
|
|||||||
let book = concat!(
|
let book = concat!(
|
||||||
" Name one \n one@eins.org \n",
|
" Name one \n one@eins.org \n",
|
||||||
"Name two\ntwo@deux.net\n",
|
"Name two\ntwo@deux.net\n",
|
||||||
|
"Invalid\n+1234567890\n", // invalid, should be ignored
|
||||||
"\nthree@drei.sam\n",
|
"\nthree@drei.sam\n",
|
||||||
"Name two\ntwo@deux.net\n" // should not be added again
|
"Name two\ntwo@deux.net\n" // should not be added again
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user