mirror of https://github.com/djcb/mu.git
lib: implement mu_store_update
This commit is contained in:
parent
2ee65f5b1a
commit
fe6582c6d6
|
@ -343,12 +343,29 @@ Store::add_message (const std::string& path)
|
|||
const auto docid{add_or_update_msg (store, 0, msg, &gerr)};
|
||||
mu_msg_unref (msg);
|
||||
if (G_UNLIKELY(docid == MU_STORE_INVALID_DOCID))
|
||||
throw Error{Error::Code::Message, "failed to store message: %s",
|
||||
throw Error{Error::Code::Message, "failed to add message: %s",
|
||||
gerr ? gerr->message : "something went wrong"};
|
||||
|
||||
return docid;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Store::update_message (MuMsg *msg, unsigned docid)
|
||||
{
|
||||
auto store{reinterpret_cast<MuStore*>(this)}; // yuk.
|
||||
|
||||
GError *gerr{};
|
||||
const auto docid2{add_or_update_msg (store, docid, msg, &gerr)};
|
||||
|
||||
if (G_UNLIKELY(docid != docid2))
|
||||
throw Error{Error::Code::Internal, "failed to update message",
|
||||
gerr ? gerr->message : "something went wrong"};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Store::remove_message (const std::string& path)
|
||||
{
|
||||
|
|
|
@ -122,6 +122,16 @@ public:
|
|||
*/
|
||||
unsigned add_message (const std::string& path);
|
||||
|
||||
/**
|
||||
* Update a message in the store.
|
||||
*
|
||||
* @param msg a message
|
||||
* @param docid a docid
|
||||
*
|
||||
* @return false in case of failure; true ottherwise.
|
||||
*/
|
||||
bool update_message (MuMsg *msg, unsigned docid);
|
||||
|
||||
/**
|
||||
* Add a message to the store.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue