store: update for new sexp api

And use improved cached_sexp api (automatically handled with
mu-document now)
This commit is contained in:
Dirk-Jan C. Binnema 2022-11-07 18:35:25 +02:00
parent e1dd6f10b1
commit a417b38624
3 changed files with 9 additions and 12 deletions

View File

@ -262,11 +262,10 @@ struct Store::Private {
Result<Store::Id>
Store::Private::update_message_unlocked(Message& msg, Store::Id docid)
{
msg.update_cached_sexp();
return xapian_try_result([&]{
writable_db().replace_document(docid, msg.document().xapian_document());
g_debug("updated message @ %s; docid = %u", msg.path().c_str(), docid);
//g_info("%s", msg.sexp().to_string().c_str());
writable_db().set_metadata(ChangedKey, tstamp_to_string(::time({})));
return Ok(std::move(docid));
});
@ -275,8 +274,6 @@ Store::Private::update_message_unlocked(Message& msg, Store::Id docid)
Result<Store::Id>
Store::Private::update_message_unlocked(Message& msg, const std::string& path_to_replace)
{
msg.update_cached_sexp();
return xapian_try_result([&]{
auto id = writable_db().replace_document(
field_from_id(Field::Id::Path).xapian_term(path_to_replace),

View File

@ -574,13 +574,13 @@ Boo!
g_assert_false(::access(old_path.c_str(), F_OK) == 0);
g_assert_true(::access(new_path.c_str(), F_OK) == 0);
/* also ensure thath the cached sexp for the message has been updated;
/* also ensure that the cached sexp for the message has been updated;
* that's what mu4e uses */
const auto moved_sexp{moved_msg->to_sexp()};
g_assert_true(moved_sexp.is_prop_list());
const auto plist{Sexp::List(moved_sexp.list())};
g_assert_true(plist.has_prop(":path"));
assert_equal(plist.find_prop(":path").value(), new_path);
const auto moved_sexp{moved_msg->sexp()};
//std::cerr << "@@ " << *moved_msg << '\n';
g_assert_true(moved_sexp.plistp());
g_assert_true(moved_sexp.has_prop(":path"));
assert_equal(moved_sexp.get_prop(":path").string(), new_path);
/*
* find new message with query, ensure it's really that new one.

View File

@ -368,7 +368,7 @@ Yes, that would be excellent.
const auto oldpath{msg->path()};
assert_equal(msg->subject(), "Re: multi-eq hash tables");
g_assert_true(msg->docid() != 0);
g_debug("%s", msg->to_sexp().to_sexp_string().c_str());
g_debug("%s", msg->sexp().to_string().c_str());
// Move the message from new->cur
std::this_thread::sleep_for(1s); /* ctime should change */
@ -379,7 +379,7 @@ Yes, that would be excellent.
g_assert_true(::access(msg3->path().c_str(), R_OK)==0);
g_assert_false(::access(oldpath.c_str(), R_OK)==0);
g_debug("%s", msg3->to_sexp().to_sexp_string().c_str());
g_debug("%s", msg3->sexp().to_string().c_str());
g_assert_cmpuint(store->size(), ==, 1);
}