lib: xapian-db/config: more tests

...and xapian-db gets a small API update, update store as well.
This commit is contained in:
Dirk-Jan C. Binnema
2023-09-23 09:27:46 +03:00
parent 11003000e8
commit 655a6b0499
5 changed files with 121 additions and 31 deletions

View File

@ -165,29 +165,30 @@ struct Store::Private {
Result<Store::Id>
Store::Private::add_message_unlocked(Message& msg)
{
auto docid{xapian_db_.add_document(msg.document().xapian_document())};
mu_debug("added message @ {}; docid = {}", msg.path(), docid);
auto&& docid{xapian_db_.add_document(msg.document().xapian_document())};
if (docid)
mu_debug("added message @ {}; docid = {}", msg.path(), *docid);
return Ok(std::move(docid));
return docid;
}
Result<Store::Id>
Store::Private::update_message_unlocked(Message& msg, Store::Id docid)
{
xapian_db_.replace_document(docid, msg.document().xapian_document());
mu_debug("updated message @ {}; docid = {}", msg.path(), docid);
auto&& res{xapian_db_.replace_document(docid, msg.document().xapian_document())};
if (res)
mu_debug("updated message @ {}; docid = {}", msg.path(), *res);
return Ok(std::move(docid));
return res;
}
Result<Store::Id>
Store::Private::update_message_unlocked(Message& msg, const std::string& path_to_replace)
{
auto id = xapian_db_.replace_document(
return xapian_db_.replace_document(
field_from_id(Field::Id::Path).xapian_term(path_to_replace),
msg.document().xapian_document());
return Ok(std::move(id));
}
Option<Message>