* mu-msg: add mu_msg_close_file_backend
This commit is contained in:
11
src/mu-msg.c
11
src/mu-msg.c
@ -107,6 +107,16 @@ mu_msg_new_from_file (const char *path, const char *mdir, GError **err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
mu_msg_close_file_backend (MuMsg *msg)
|
||||||
|
{
|
||||||
|
g_return_if_fail (msg);
|
||||||
|
|
||||||
|
mu_msg_file_destroy (msg->_file);
|
||||||
|
msg->_file = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MuMsg*
|
MuMsg*
|
||||||
mu_msg_new_from_doc (XapianDocument *doc, GError **err)
|
mu_msg_new_from_doc (XapianDocument *doc, GError **err)
|
||||||
{
|
{
|
||||||
@ -310,6 +320,7 @@ get_num_field (MuMsg *self, MuMsgFieldId mfid)
|
|||||||
{
|
{
|
||||||
guint64 val;
|
guint64 val;
|
||||||
|
|
||||||
|
/* first try the cache */
|
||||||
if (mu_msg_cache_cached (self->_cache, mfid))
|
if (mu_msg_cache_cached (self->_cache, mfid))
|
||||||
return mu_msg_cache_num (self->_cache, mfid);
|
return mu_msg_cache_num (self->_cache, mfid);
|
||||||
|
|
||||||
|
|||||||
12
src/mu-msg.h
12
src/mu-msg.h
@ -69,6 +69,18 @@ MuMsg *mu_msg_new_from_doc (XapianDocument* doc, GError **err)
|
|||||||
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* close the file-backend, if any; this function is for the use case
|
||||||
|
* where you have a large amount of messages where you need some
|
||||||
|
* file-backed field (body or attachments). If you don't close the
|
||||||
|
* file-backend after retrieving the desired field, you'd quickly run
|
||||||
|
* out of file descriptors. If this message does not have a
|
||||||
|
* file-backend, do nothing.
|
||||||
|
*
|
||||||
|
* @param msg a message object
|
||||||
|
*/
|
||||||
|
void mu_msg_close_file_backend (MuMsg *msg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* increase the reference count for this message
|
* increase the reference count for this message
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user