* mu-store*: use GError, stability fixes + cleanups

This commit is contained in:
Dirk-Jan C. Binnema
2011-09-03 10:45:14 +03:00
parent 0ad110d241
commit bd1ae1a124
4 changed files with 153 additions and 140 deletions

View File

@ -47,32 +47,20 @@ private:
struct _MuStore { struct _MuStore {
public:
/* create a read-write MuStore */
_MuStore (const char *path, const char *contacts_path, bool rebuild) {
/* by default, use transactions of 30000 messages */ init (path, contacts_path, rebuild, false);
#define MU_STORE_DEFAULT_BATCH_SIZE 30000
/* http://article.gmane.org/gmane.comp.search.xapian.general/3656 */
#define MU_STORE_MAX_TERM_LENGTH 240
_MuStore (const char *path, const char *contacts_path, bool read_only): if (rebuild)
_in_transaction (false), _processed (0), _db = new Xapian::WritableDatabase
_batch_size(MU_STORE_DEFAULT_BATCH_SIZE), (path, Xapian::DB_CREATE_OR_OVERWRITE);
_contacts(0), _path (0), _version(0),
_db(0), _read_only(read_only), _ref_count (1) {
if (!check_path ())
throw MuStoreError (MU_ERROR_FILE, "invalid_path");
_path = g_strdup (path);
if (read_only)
_db = new Xapian::Database (path);
else else
_db = new Xapian::WritableDatabase _db = new Xapian::WritableDatabase
(path, Xapian::DB_CREATE_OR_OPEN); (path, Xapian::DB_CREATE_OR_OPEN);
if (!check_version ()) check_set_version ();
throw MuStoreError (MU_ERROR_XAPIAN_NOT_UP_TO_DATE,
("xapian db version check failed"));
if (contacts_path) { if (contacts_path) {
_contacts = mu_contacts_new (contacts_path); _contacts = mu_contacts_new (contacts_path);
@ -80,24 +68,64 @@ struct _MuStore {
throw MuStoreError (MU_ERROR_FILE, throw MuStoreError (MU_ERROR_FILE,
("failed to init contacts cache")); ("failed to init contacts cache"));
} }
MU_WRITE_LOG ("%s: opened %s (batch size: %u)",
MU_WRITE_LOG ("%s: opened %s (batch size: %u) for read-write",
__FUNCTION__, this->path(), batch_size()); __FUNCTION__, this->path(), batch_size());
} }
/* create a read-only MuStore */
_MuStore (const char *path) {
init (path, NULL, false, false);
_db = new Xapian::Database (path);
if (mu_store_needs_upgrade(this))
throw MuStoreError (MU_ERROR_XAPIAN_NOT_UP_TO_DATE,
("store needs an upgrade"));
MU_WRITE_LOG ("%s: opened %s read-only", __FUNCTION__, this->path());
}
void init (const char *path, const char *contacts_path,
bool rebuild, bool read_only) {
_batch_size = DEFAULT_BATCH_SIZE;
_contacts = 0;
_in_transaction = false;
_path = path;
_processed = 0;
_read_only = read_only;
_ref_count = 1;
_version = NULL;
}
void check_set_version () {
/* check version...*/
gchar *version;
version = mu_store_get_metadata (this, MU_STORE_VERSION_KEY, NULL);
if (!version)
mu_store_set_metadata (this, MU_STORE_VERSION_KEY,
MU_STORE_SCHEMA_VERSION, NULL);
else if (g_strcmp0 (version, MU_STORE_SCHEMA_VERSION) != 0) {
g_free (version);
throw MuStoreError (MU_ERROR_XAPIAN_NOT_UP_TO_DATE,
("store needs an upgrade"));
} else
g_free (version);
}
~_MuStore () { ~_MuStore () {
try { try {
if (_ref_count != 0) if (_ref_count != 0)
g_warning ("ref count != 0"); g_warning ("ref count != 0");
g_free (_version); g_free (_version);
g_free (_path);
mu_contacts_destroy (_contacts); mu_contacts_destroy (_contacts);
if (!_read_only) if (!_read_only)
mu_store_flush (this); mu_store_flush (this);
MU_WRITE_LOG ("closing xapian database with %d documents", MU_WRITE_LOG ("closing xapian database with %d document(s)",
(int)db_read_only()->get_doccount()); (int)db_read_only()->get_doccount());
delete _db; delete _db;
@ -105,7 +133,20 @@ struct _MuStore {
} }
/* close the old database, and write an empty one on top of it */ /* close the old database, and write an empty one on top of it */
void clear(); void clear () {
if (is_read_only())
throw std::runtime_error ("database is read-only");
// clear the database
db_writable()->close ();
delete _db;
_db = new Xapian::WritableDatabase
(path(), Xapian::DB_CREATE_OR_OVERWRITE);
// clear the contacts cache
if (_contacts)
mu_contacts_clear (_contacts);
}
/* get a unique id for this message; note, this function returns a /* get a unique id for this message; note, this function returns a
* static buffer -- not reentrant */ * static buffer -- not reentrant */
@ -116,10 +157,16 @@ struct _MuStore {
const char* version () { const char* version () {
g_free (_version); g_free (_version);
return _version = return _version = mu_store_get_metadata (this, MU_STORE_VERSION_KEY,
mu_store_get_metadata (this, MU_STORE_VERSION_KEY); NULL);
} }
void set_version (const char *version) {
mu_store_set_metadata (this, MU_STORE_VERSION_KEY, version, NULL);
}
static unsigned max_term_length() { return MAX_TERM_LENGTH; }
void begin_transaction (); void begin_transaction ();
void commit_transaction (); void commit_transaction ();
void rollback_transaction (); void rollback_transaction ();
@ -132,12 +179,12 @@ struct _MuStore {
Xapian::Database* db_read_only() const { return _db; } Xapian::Database* db_read_only() const { return _db; }
const char* path () const { return _path; } const char* path () const { return _path.c_str(); }
bool is_read_only () const { return _read_only; } bool is_read_only () const { return _read_only; }
size_t batch_size () const { return _batch_size;} size_t batch_size () const { return _batch_size;}
size_t set_batch_size (size_t n) { size_t set_batch_size (size_t n) {
return _batch_size = ( n == 0) ? MU_STORE_DEFAULT_BATCH_SIZE : n; return _batch_size = ( n == 0) ? DEFAULT_BATCH_SIZE : n;
} }
bool in_transaction () const { return _in_transaction; } bool in_transaction () const { return _in_transaction; }
@ -151,13 +198,12 @@ struct _MuStore {
guint ref () { return ++_ref_count; } guint ref () { return ++_ref_count; }
guint unref () { return --_ref_count; } guint unref () { return --_ref_count; }
/* by default, use transactions of 30000 messages */
static const unsigned DEFAULT_BATCH_SIZE = 30000;
/* http://article.gmane.org/gmane.comp.search.xapian.general/3656 */
static const unsigned MAX_TERM_LENGTH = 240;
private: private:
bool check_version ();
bool check_path () {
return true; // FIXME
}
/* transaction handling */ /* transaction handling */
bool _in_transaction; bool _in_transaction;
int _processed; int _processed;
@ -166,8 +212,8 @@ private:
/* contacts object to cache all the contact information */ /* contacts object to cache all the contact information */
MuContacts *_contacts; MuContacts *_contacts;
char *_path; std::string _path;
mutable char *_version; gchar *_version;
Xapian::Database *_db; Xapian::Database *_db;
bool _read_only; bool _read_only;

View File

@ -39,29 +39,6 @@
#include "mu-flags.h" #include "mu-flags.h"
#include "mu-contacts.h" #include "mu-contacts.h"
bool
_MuStore::check_version ()
{
const gchar *version;
version = mu_store_version (this);
/* no version yet? it must be a new db then; we'll set the version */
if (!version) {
if (!mu_store_set_metadata (this, MU_STORE_VERSION_KEY,
MU_STORE_SCHEMA_VERSION)) {
g_warning ("failed to set database version");
return FALSE;
}
return TRUE; /* ok, done. */
}
/* we have a version, but is it the right one? */
return mu_store_needs_upgrade (this) ? FALSE : TRUE;
}
/* get a unique id for this message; note, this function returns a /* get a unique id for this message; note, this function returns a
* static buffer -- not reentrant */ * static buffer -- not reentrant */
const char* const char*
@ -91,14 +68,13 @@ mu_store_new_read_only (const char* xpath, GError **err)
g_return_val_if_fail (xpath, NULL); g_return_val_if_fail (xpath, NULL);
try { try {
return new _MuStore (xpath, NULL, true); return new _MuStore (xpath);
} catch (const MuStoreError& merr) { } catch (const MuStoreError& merr) {
g_set_error (err, 0, merr.mu_error(), "%s", g_set_error (err, 0, merr.mu_error(), "%s",
merr.what().c_str()); merr.what().c_str());
} MU_XAPIAN_CATCH_BLOCK_G_ERROR(err,MU_ERROR_XAPIAN); } MU_XAPIAN_CATCH_BLOCK_G_ERROR(err, MU_ERROR_XAPIAN);
return NULL; return NULL;
} }
@ -113,18 +89,20 @@ mu_store_is_read_only (MuStore *store)
return store->is_read_only() ? TRUE : FALSE; return store->is_read_only() ? TRUE : FALSE;
} MU_XAPIAN_CATCH_BLOCK_RETURN(FALSE); } MU_XAPIAN_CATCH_BLOCK_RETURN(FALSE);
} }
unsigned unsigned
mu_store_count (MuStore *store) mu_store_count (MuStore *store, GError **err)
{ {
g_return_val_if_fail (store, 0); g_return_val_if_fail (store, (unsigned)-1);
try { try {
return store->db_read_only()->get_doccount(); return store->db_read_only()->get_doccount();
} MU_XAPIAN_CATCH_BLOCK_RETURN(0); } MU_XAPIAN_CATCH_BLOCK_G_ERROR_RETURN(err, MU_ERROR_XAPIAN,
(unsigned)-1);
} }
@ -148,7 +126,7 @@ mu_store_needs_upgrade (MuStore *store)
char* char*
mu_store_get_metadata (MuStore *store, const char *key) mu_store_get_metadata (MuStore *store, const char *key, GError **err)
{ {
g_return_val_if_fail (store, NULL); g_return_val_if_fail (store, NULL);
g_return_val_if_fail (key, NULL); g_return_val_if_fail (key, NULL);
@ -157,7 +135,7 @@ mu_store_get_metadata (MuStore *store, const char *key)
const std::string val (store->db_read_only()->get_metadata (key)); const std::string val (store->db_read_only()->get_metadata (key));
return val.empty() ? NULL : g_strdup (val.c_str()); return val.empty() ? NULL : g_strdup (val.c_str());
} MU_XAPIAN_CATCH_BLOCK_RETURN(NULL); } MU_XAPIAN_CATCH_BLOCK_G_ERROR_RETURN(err, MU_ERROR_XAPIAN, NULL);
} }
@ -171,7 +149,7 @@ mu_store_get_read_only_database (MuStore *store)
gboolean gboolean
mu_store_contains_message (MuStore *store, const char* path) mu_store_contains_message (MuStore *store, const char* path, GError **err)
{ {
g_return_val_if_fail (store, FALSE); g_return_val_if_fail (store, FALSE);
g_return_val_if_fail (path, FALSE); g_return_val_if_fail (path, FALSE);
@ -180,13 +158,14 @@ mu_store_contains_message (MuStore *store, const char* path)
const std::string uid (store->get_message_uid(path)); const std::string uid (store->get_message_uid(path));
return store->db_read_only()->term_exists (uid) ? TRUE: FALSE; return store->db_read_only()->term_exists (uid) ? TRUE: FALSE;
} MU_XAPIAN_CATCH_BLOCK_RETURN (FALSE); } MU_XAPIAN_CATCH_BLOCK_G_ERROR_RETURN(err, MU_ERROR_XAPIAN, FALSE);
} }
time_t time_t
mu_store_get_timestamp (MuStore *store, const char* msgpath) mu_store_get_timestamp (MuStore *store, const char* msgpath, GError **err)
{ {
char *stampstr; char *stampstr;
time_t rv; time_t rv;
@ -194,7 +173,7 @@ mu_store_get_timestamp (MuStore *store, const char* msgpath)
g_return_val_if_fail (store, 0); g_return_val_if_fail (store, 0);
g_return_val_if_fail (msgpath, 0); g_return_val_if_fail (msgpath, 0);
stampstr = mu_store_get_metadata (store, msgpath); stampstr = mu_store_get_metadata (store, msgpath, err);
if (!stampstr) if (!stampstr)
return (time_t)0; return (time_t)0;
@ -208,7 +187,7 @@ mu_store_get_timestamp (MuStore *store, const char* msgpath)
MuError MuError
mu_store_foreach (MuStore *self, mu_store_foreach (MuStore *self,
MuStoreForeachFunc func, void *user_data) MuStoreForeachFunc func, void *user_data, GError **err)
{ {
g_return_val_if_fail (self, MU_ERROR); g_return_val_if_fail (self, MU_ERROR);
g_return_val_if_fail (func, MU_ERROR); g_return_val_if_fail (func, MU_ERROR);
@ -233,7 +212,8 @@ mu_store_foreach (MuStore *self,
return res; return res;
} }
} MU_XAPIAN_CATCH_BLOCK_RETURN (MU_ERROR); } MU_XAPIAN_CATCH_BLOCK_G_ERROR_RETURN(err, MU_ERROR_XAPIAN,
MU_ERROR_XAPIAN);
return MU_OK; return MU_OK;
} }

View File

@ -66,26 +66,6 @@ _MuStore::rollback_transaction () {
} }
/* close the old database, and write an empty one on top of it */
void
_MuStore::clear ()
{
if (is_read_only())
throw std::runtime_error ("database is read-only");
// clear the database
db_writable()->close ();
delete _db;
_db = new Xapian::WritableDatabase
(path(), Xapian::DB_CREATE_OR_OVERWRITE);
// clear the contacts cache
if (_contacts)
mu_contacts_clear (_contacts);
}
/* we cache these prefix strings, so we don't have to allocate the all /* we cache these prefix strings, so we don't have to allocate the all
* the time; this should save 10-20 string allocs per message */ * the time; this should save 10-20 string allocs per message */
G_GNUC_CONST static const std::string& G_GNUC_CONST static const std::string&
@ -143,25 +123,21 @@ add_synonyms (MuStore *store)
MuStore* MuStore*
mu_store_new_writable (const char* xpath, const char *contacts_cache, mu_store_new_writable (const char* xpath, const char *contacts_cache,
GError **err) gboolean rebuild, GError **err)
{ {
g_return_val_if_fail (xpath, NULL); g_return_val_if_fail (xpath, NULL);
try { try {
MuStore *store; try {
MuStore *store;
store = new _MuStore (xpath, contacts_cache,
rebuild ? true : false);
add_synonyms (store);
return store;
store = new _MuStore (xpath, contacts_cache, false); } MU_STORE_CATCH_BLOCK_RETURN(err,NULL);
add_synonyms (store);
return store; } MU_XAPIAN_CATCH_BLOCK_G_ERROR_RETURN (err,MU_ERROR_XAPIAN, NULL);
} catch (const MuStoreError& merr) {
g_set_error (err, 0, merr.mu_error(),
"%s", merr.what().c_str());
} MU_XAPIAN_CATCH_BLOCK_G_ERROR(err,MU_ERROR_XAPIAN);
return NULL;
} }
@ -175,30 +151,35 @@ mu_store_set_batch_size (MuStore *store, guint batchsize)
gboolean gboolean
mu_store_set_metadata (MuStore *store, const char *key, const char *val) mu_store_set_metadata (MuStore *store, const char *key, const char *val,
GError **err)
{ {
g_return_val_if_fail (store, FALSE); g_return_val_if_fail (store, FALSE);
g_return_val_if_fail (key, FALSE); g_return_val_if_fail (key, FALSE);
g_return_val_if_fail (val, FALSE); g_return_val_if_fail (val, FALSE);
try { try {
store->db_writable()->set_metadata (key, val); try {
return TRUE; store->db_writable()->set_metadata (key, val);
return TRUE;
} MU_STORE_CATCH_BLOCK_RETURN(err, FALSE);
} MU_XAPIAN_CATCH_BLOCK; } MU_XAPIAN_CATCH_BLOCK_G_ERROR_RETURN(err, MU_ERROR_XAPIAN, FALSE);
return FALSE;
} }
gboolean gboolean
mu_store_clear (MuStore *store) mu_store_clear (MuStore *store, GError **err)
{ {
g_return_val_if_fail (store, FALSE); g_return_val_if_fail (store, FALSE);
try { try {
store->clear(); try {
return TRUE; store->clear();
return TRUE;
} MU_STORE_CATCH_BLOCK_RETURN(err, FALSE);
} MU_XAPIAN_CATCH_BLOCK_RETURN(FALSE); } MU_XAPIAN_CATCH_BLOCK_RETURN(FALSE);
} }
@ -347,7 +328,7 @@ add_terms_values_str (Xapian::Document& doc, char *val,
if (mu_msg_field_xapian_term(mfid)) if (mu_msg_field_xapian_term(mfid))
doc.add_term (prefix(mfid) + doc.add_term (prefix(mfid) +
std::string(val, 0, MU_STORE_MAX_TERM_LENGTH)); std::string(val, 0, _MuStore::MAX_TERM_LENGTH));
} }
@ -427,15 +408,16 @@ each_part (MuMsg *msg, MuMsgPart *part, PartData *pdata)
if (mu_msg_part_looks_like_attachment (part, TRUE) && if (mu_msg_part_looks_like_attachment (part, TRUE) &&
(part->file_name)) { (part->file_name)) {
char val[MU_STORE_MAX_TERM_LENGTH + 1]; char val[MuStore::MAX_TERM_LENGTH + 1];
strncpy (val, part->file_name, sizeof(val)); strncpy (val, part->file_name, sizeof(val));
/* now, let's create a terms... */ /* now, let's create a terms... */
mu_str_normalize_in_place (val, TRUE); mu_str_normalize_in_place (val, TRUE);
mu_str_ascii_xapian_escape_in_place (val); mu_str_ascii_xapian_escape_in_place (val);
pdata->_doc.add_term (prefix(pdata->_mfid) + pdata->_doc.add_term
std::string(val, 0, MU_STORE_MAX_TERM_LENGTH)); (prefix(pdata->_mfid) +
std::string(val, 0, MuStore::MAX_TERM_LENGTH));
} }
} }
@ -563,8 +545,7 @@ each_contact_info (MuMsgContact *contact, MsgDoc *msgdoc)
if (!mu_str_is_empty(contact->address)) { if (!mu_str_is_empty(contact->address)) {
char *escaped = mu_str_ascii_xapian_escape (contact->address); char *escaped = mu_str_ascii_xapian_escape (contact->address);
msgdoc->_doc->add_term msgdoc->_doc->add_term
(std::string (pfx + escaped, 0, (std::string (pfx + escaped, 0, MuStore::MAX_TERM_LENGTH));
MU_STORE_MAX_TERM_LENGTH));
g_free (escaped); g_free (escaped);
/* store it also in our contacts cache */ /* store it also in our contacts cache */
@ -625,6 +606,7 @@ mu_store_store_msg (MuStore *store, MuMsg *msg, gboolean replace)
} }
/* FIXME: use GError */
gboolean gboolean
mu_store_store_path (MuStore *store, const char *path) mu_store_store_path (MuStore *store, const char *path)
{ {
@ -688,7 +670,7 @@ mu_store_remove_path (MuStore *store, const char *msgpath)
gboolean gboolean
mu_store_set_timestamp (MuStore *store, const char* msgpath, mu_store_set_timestamp (MuStore *store, const char* msgpath,
time_t stamp) time_t stamp, GError **err)
{ {
char buf[21]; char buf[21];
@ -696,7 +678,7 @@ mu_store_set_timestamp (MuStore *store, const char* msgpath,
g_return_val_if_fail (msgpath, FALSE); g_return_val_if_fail (msgpath, FALSE);
sprintf (buf, "%" G_GUINT64_FORMAT, (guint64)stamp); sprintf (buf, "%" G_GUINT64_FORMAT, (guint64)stamp);
return mu_store_set_metadata (store, msgpath, buf); return mu_store_set_metadata (store, msgpath, buf, err);
} }

View File

@ -42,7 +42,7 @@ typedef struct _MuStore MuStore;
* of error; free with mu_store_unref * of error; free with mu_store_unref
*/ */
MuStore* mu_store_new_writable (const char *xpath, const char *ccachepath, MuStore* mu_store_new_writable (const char *xpath, const char *ccachepath,
GError **err) gboolean rebuild, GError **err)
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
@ -117,7 +117,6 @@ typedef gpointer XapianDatabase;
XapianDatabase* mu_store_get_read_only_database (MuStore *store); XapianDatabase* mu_store_get_read_only_database (MuStore *store);
/** /**
* set the Xapian batch size for this store. Normally, there's no need * set the Xapian batch size for this store. Normally, there's no need
* to use this function as the default is good enough; however, if you * to use this function as the default is good enough; however, if you
@ -132,17 +131,16 @@ void mu_store_set_batch_size (MuStore *store, guint batchsize);
/** /**
* get the numbers of documents in the database * get the numbers of documents in the database
* *
* @param index a valid MuStore instance * @param index a valid MuStore instance
* @param err to receive error info or NULL. err->code is MuError value
* *
* @return the number of documents in the database; 0 in case of error * @return the number of documents in the database; (unsigned)-1 in
* or an empty database * case of error
*/ */
unsigned mu_store_count (MuStore *store); unsigned mu_store_count (MuStore *store, GError **err);
/** /**
* get a version string for the database; it's a const string, which * get a version string for the database; it's a const string, which
@ -210,10 +208,12 @@ gboolean mu_store_remove_path (MuStore *store, const char* msgpath);
* *
* @param store a store * @param store a store
* @param path the message path * @param path the message path
* @param err to receive error info or NULL. err->code is MuError value
* *
* @return TRUE if the message exists, FALSE otherwise * @return TRUE if the message exists, FALSE otherwise
*/ */
gboolean mu_store_contains_message (MuStore *store, const char* path); gboolean mu_store_contains_message (MuStore *store, const char* path,
GError **err);
/** /**
* store a timestamp for a directory * store a timestamp for a directory
@ -221,22 +221,24 @@ gboolean mu_store_contains_message (MuStore *store, const char* path);
* @param store a valid store * @param store a valid store
* @param msgpath path to a maildir * @param msgpath path to a maildir
* @param stamp a timestamp * @param stamp a timestamp
* @param err to receive error info or NULL. err->code is MuError value
* *
* @return TRUE if setting the timestamp succeeded, FALSE otherwise * @return TRUE if setting the timestamp succeeded, FALSE otherwise
*/ */
gboolean mu_store_set_timestamp (MuStore *store, const char* msgpath, gboolean mu_store_set_timestamp (MuStore *store, const char* msgpath,
time_t stamp); time_t stamp, GError **err);
/** /**
* get the timestamp for a directory * get the timestamp for a directory
* *
* @param store a valid store * @param store a valid store
* @param msgpath path to a maildir * @param msgpath path to a maildir
* @param err to receive error info or NULL. err->code is MuError value
* *
* @return the timestamp, or 0 in case of error * @return the timestamp, or 0 in case of error
*/ */
time_t mu_store_get_timestamp (MuStore *store, time_t mu_store_get_timestamp (MuStore *store, const char* msgpath,
const char* msgpath); GError **err);
/** /**
@ -256,6 +258,7 @@ gboolean mu_store_is_read_only (MuStore *store);
* @param self a valid store * @param self a valid store
* @param func a callback function to to call for each document * @param func a callback function to to call for each document
* @param user_data a user pointer passed to the callback function * @param user_data a user pointer passed to the callback function
* @param err to receive error info or NULL. err->code is MuError value
* *
* @return MU_OK if all went well, MU_STOP if the foreach was interrupted, * @return MU_OK if all went well, MU_STOP if the foreach was interrupted,
* MU_ERROR in case of error * MU_ERROR in case of error
@ -263,7 +266,7 @@ gboolean mu_store_is_read_only (MuStore *store);
typedef MuError (*MuStoreForeachFunc) (const char* path, typedef MuError (*MuStoreForeachFunc) (const char* path,
void *user_data); void *user_data);
MuError mu_store_foreach (MuStore *self, MuStoreForeachFunc func, MuError mu_store_foreach (MuStore *self, MuStoreForeachFunc func,
void *user_data); void *user_data, GError **err);
/** /**
* set metadata for this MuStore * set metadata for this MuStore
@ -271,21 +274,24 @@ MuError mu_store_foreach (MuStore *self, MuStoreForeachFunc func,
* @param store a store * @param store a store
* @param key metadata key * @param key metadata key
* @param val metadata value * @param val metadata value
* @param err to receive error info or NULL. err->code is the MuError value
* *
* @return TRUE if succeeded, FALSE otherwise * @return TRUE if succeeded, FALSE otherwise
*/ */
gboolean mu_store_set_metadata (MuStore *store, const char *key, const char *val); gboolean mu_store_set_metadata (MuStore *store, const char *key, const char *val,
GError **err);
/** /**
* get metadata for this MuStore * get metadata for this MuStore
* *
* @param store a store * @param store a store
* @param key the metadata key * @param key the metadata key
* @param err to receive error info or NULL. err->code is MuError value
* *
* @return the value of the metadata (gfree when done with it), or * @return the value of the metadata (gfree when done with it), or
* NULL in case of error * NULL in case of error
*/ */
char* mu_store_get_metadata (MuStore *store, const char *key) char* mu_store_get_metadata (MuStore *store, const char *key, GError **err)
G_GNUC_WARN_UNUSED_RESULT; G_GNUC_WARN_UNUSED_RESULT;
@ -312,18 +318,17 @@ gchar* mu_store_database_version (const gchar *xpath) G_GNUC_WARN_UNUSED_RESULT;
*/ */
gboolean mu_store_needs_upgrade (MuStore *store); gboolean mu_store_needs_upgrade (MuStore *store);
/** /**
* clear the database, ie., remove all of the contents. This is a * clear the database, ie., remove all of the contents. This is a
* destructive operation, but the database can be restored be doing a * destructive operation, but the database can be restored be doing a
* full scan of the maildirs. Also, clear the contacts cache file * full scan of the maildirs. Also, clear the contacts cache file
* *
* @param store a MuStore object * @param store a MuStore object
* @param err to receive error info or NULL. err->code is MuError value
* *
* @return TRUE if the clearing succeeded, FALSE otherwise. * @return TRUE if the clearing succeeded, FALSE otherwise.
*/ */
gboolean mu_store_clear (MuStore *store); gboolean mu_store_clear (MuStore *store, GError **err);
/** /**