lib: implement mu_store_update
This commit is contained in:
@ -343,12 +343,29 @@ Store::add_message (const std::string& path)
|
|||||||
const auto docid{add_or_update_msg (store, 0, msg, &gerr)};
|
const auto docid{add_or_update_msg (store, 0, msg, &gerr)};
|
||||||
mu_msg_unref (msg);
|
mu_msg_unref (msg);
|
||||||
if (G_UNLIKELY(docid == MU_STORE_INVALID_DOCID))
|
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"};
|
gerr ? gerr->message : "something went wrong"};
|
||||||
|
|
||||||
return docid;
|
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
|
bool
|
||||||
Store::remove_message (const std::string& path)
|
Store::remove_message (const std::string& path)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -122,6 +122,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
unsigned add_message (const std::string& path);
|
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.
|
* Add a message to the store.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user