mirror of https://github.com/djcb/mu.git
* some minor updates in mu-store version check
This commit is contained in:
parent
d60fd4bb47
commit
e8f4f5976d
|
@ -97,7 +97,6 @@ public:
|
||||||
_processed = 0;
|
_processed = 0;
|
||||||
_read_only = read_only;
|
_read_only = read_only;
|
||||||
_ref_count = 1;
|
_ref_count = 1;
|
||||||
_version = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_my_addresses (const char **my_addresses) {
|
void set_my_addresses (const char **my_addresses) {
|
||||||
|
@ -124,7 +123,7 @@ public:
|
||||||
else if (g_strcmp0 (version, MU_STORE_SCHEMA_VERSION) != 0) {
|
else if (g_strcmp0 (version, MU_STORE_SCHEMA_VERSION) != 0) {
|
||||||
g_free (version);
|
g_free (version);
|
||||||
throw MuStoreError (MU_ERROR_XAPIAN_NOT_UP_TO_DATE,
|
throw MuStoreError (MU_ERROR_XAPIAN_NOT_UP_TO_DATE,
|
||||||
("store needs an upgrade"));
|
"store needs an upgrade");
|
||||||
} else
|
} else
|
||||||
g_free (version);
|
g_free (version);
|
||||||
}
|
}
|
||||||
|
@ -134,8 +133,6 @@ public:
|
||||||
if (_ref_count != 0)
|
if (_ref_count != 0)
|
||||||
g_warning ("ref count != 0");
|
g_warning ("ref count != 0");
|
||||||
|
|
||||||
g_free (_version);
|
|
||||||
|
|
||||||
mu_contacts_destroy (_contacts);
|
mu_contacts_destroy (_contacts);
|
||||||
if (!_read_only)
|
if (!_read_only)
|
||||||
mu_store_flush (this);
|
mu_store_flush (this);
|
||||||
|
@ -165,14 +162,15 @@ public:
|
||||||
mu_contacts_clear (_contacts);
|
mu_contacts_clear (_contacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_uid_term (const char *path);
|
std::string get_uid_term (const char *path) const;
|
||||||
|
|
||||||
MuContacts* contacts() { return _contacts; }
|
MuContacts* contacts() { return _contacts; }
|
||||||
|
|
||||||
const char* version () {
|
const std::string version () const {
|
||||||
g_free (_version);
|
char *v = mu_store_get_metadata (this, MU_STORE_VERSION_KEY, NULL);
|
||||||
return _version = mu_store_get_metadata (this, MU_STORE_VERSION_KEY,
|
_version = v;
|
||||||
NULL);
|
g_free (v);
|
||||||
|
return _version;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_version (const char *version) {
|
void set_version (const char *version) {
|
||||||
|
@ -233,7 +231,7 @@ private:
|
||||||
MuContacts *_contacts;
|
MuContacts *_contacts;
|
||||||
|
|
||||||
std::string _path;
|
std::string _path;
|
||||||
gchar *_version;
|
mutable std::string _version;
|
||||||
|
|
||||||
Xapian::Database *_db;
|
Xapian::Database *_db;
|
||||||
bool _read_only;
|
bool _read_only;
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
// note: not re-entrant
|
// note: not re-entrant
|
||||||
std::string
|
std::string
|
||||||
_MuStore::get_uid_term (const char* path)
|
_MuStore::get_uid_term (const char* path) const
|
||||||
{
|
{
|
||||||
char real_path[PATH_MAX + 1];
|
char real_path[PATH_MAX + 1];
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ mu_store_new_read_only (const char* xpath, GError **err)
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mu_store_is_read_only (MuStore *store)
|
mu_store_is_read_only (const MuStore *store)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (store, FALSE);
|
g_return_val_if_fail (store, FALSE);
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ mu_store_is_read_only (MuStore *store)
|
||||||
|
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
mu_store_count (MuStore *store, GError **err)
|
mu_store_count (const MuStore *store, GError **err)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (store, (unsigned)-1);
|
g_return_val_if_fail (store, (unsigned)-1);
|
||||||
|
|
||||||
|
@ -110,25 +110,30 @@ mu_store_count (MuStore *store, GError **err)
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
mu_store_version (MuStore *store)
|
mu_store_version (const MuStore *store)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (store, NULL);
|
g_return_val_if_fail (store, NULL);
|
||||||
return store->version ();
|
return store->version().c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mu_store_needs_upgrade (MuStore *store)
|
mu_store_needs_upgrade (const MuStore *store)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (store, TRUE);
|
g_return_val_if_fail (store, TRUE);
|
||||||
|
|
||||||
return (g_strcmp0 (mu_store_version (store),
|
MU_WRITE_LOG ("'%s' '%s'\n", mu_store_version(store), MU_STORE_SCHEMA_VERSION);
|
||||||
MU_STORE_SCHEMA_VERSION) == 0) ? FALSE : TRUE;
|
|
||||||
|
if (g_strcmp0 (mu_store_version (store),
|
||||||
|
MU_STORE_SCHEMA_VERSION) == 0)
|
||||||
|
return FALSE;
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char*
|
char*
|
||||||
mu_store_get_metadata (MuStore *store, const char *key, GError **err)
|
mu_store_get_metadata (const 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);
|
||||||
|
@ -151,7 +156,7 @@ mu_store_get_read_only_database (MuStore *store)
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mu_store_contains_message (MuStore *store, const char* path, GError **err)
|
mu_store_contains_message (const 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);
|
||||||
|
@ -166,7 +171,7 @@ mu_store_contains_message (MuStore *store, const char* path, GError **err)
|
||||||
|
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
mu_store_get_docid_for_path (MuStore *store, const char* path, GError **err)
|
mu_store_get_docid_for_path (const 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);
|
||||||
|
@ -192,7 +197,7 @@ mu_store_get_docid_for_path (MuStore *store, const char* path, GError **err)
|
||||||
|
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
mu_store_get_timestamp (MuStore *store, const char *msgpath, GError **err)
|
mu_store_get_timestamp (const MuStore *store, const char *msgpath, GError **err)
|
||||||
{
|
{
|
||||||
char *stampstr;
|
char *stampstr;
|
||||||
time_t rv;
|
time_t rv;
|
||||||
|
@ -248,7 +253,7 @@ mu_store_foreach (MuStore *self,
|
||||||
|
|
||||||
|
|
||||||
MuMsg*
|
MuMsg*
|
||||||
mu_store_get_msg (MuStore *self, unsigned docid, GError **err)
|
mu_store_get_msg (const MuStore *self, unsigned docid, GError **err)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (self, NULL);
|
g_return_val_if_fail (self, NULL);
|
||||||
g_return_val_if_fail (docid != 0, NULL);
|
g_return_val_if_fail (docid != 0, NULL);
|
||||||
|
|
|
@ -153,7 +153,7 @@ void mu_store_set_my_addresses (MuStore *store, const char **my_addresses);
|
||||||
* @return the number of documents in the database; (unsigned)-1 in
|
* @return the number of documents in the database; (unsigned)-1 in
|
||||||
* case of error
|
* case of error
|
||||||
*/
|
*/
|
||||||
unsigned mu_store_count (MuStore *store, GError **err);
|
unsigned mu_store_count (const 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
|
||||||
|
@ -164,7 +164,7 @@ unsigned mu_store_count (MuStore *store, GError **err);
|
||||||
*
|
*
|
||||||
* @return the version string or NULL in case of error
|
* @return the version string or NULL in case of error
|
||||||
*/
|
*/
|
||||||
const char* mu_store_version (MuStore *store);
|
const char* mu_store_version (const MuStore *store);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,7 +244,7 @@ gboolean mu_store_remove_path (MuStore *store, const char* msgpath);
|
||||||
*
|
*
|
||||||
* @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 (const MuStore *store, const char* path,
|
||||||
GError **err);
|
GError **err);
|
||||||
|
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ gboolean mu_store_contains_message (MuStore *store, const char* path,
|
||||||
*
|
*
|
||||||
* @return the docid if the message was found, MU_STORE_INVALID_DOCID (0) otherwise
|
* @return the docid if the message was found, MU_STORE_INVALID_DOCID (0) otherwise
|
||||||
* */
|
* */
|
||||||
unsigned mu_store_get_docid_for_path (MuStore *store, const char* path, GError **err);
|
unsigned mu_store_get_docid_for_path (const MuStore *store, const char* path, GError **err);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* store a timestamp for a directory
|
* store a timestamp for a directory
|
||||||
|
@ -282,7 +282,7 @@ gboolean mu_store_set_timestamp (MuStore *store, const char* msgpath,
|
||||||
*
|
*
|
||||||
* @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, const char* msgpath,
|
time_t mu_store_get_timestamp (const MuStore *store, const char* msgpath,
|
||||||
GError **err);
|
GError **err);
|
||||||
|
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ time_t mu_store_get_timestamp (MuStore *store, const char* msgpath,
|
||||||
* @return TRUE if the store is read-only, FALSE otherwise (and in
|
* @return TRUE if the store is read-only, FALSE otherwise (and in
|
||||||
* case of error)
|
* case of error)
|
||||||
*/
|
*/
|
||||||
gboolean mu_store_is_read_only (MuStore *store);
|
gboolean mu_store_is_read_only (const MuStore *store);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -335,7 +335,7 @@ gboolean mu_store_set_metadata (MuStore *store, const char *key, const char *val
|
||||||
* @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, GError **err)
|
char* mu_store_get_metadata (const MuStore *store, const char *key, GError **err)
|
||||||
G_GNUC_WARN_UNUSED_RESULT;
|
G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ gchar* mu_store_database_version (const gchar *xpath) G_GNUC_WARN_UNUSED_RESULT;
|
||||||
*
|
*
|
||||||
* @return TRUE if the database needs upgrading, FALSE otherwise
|
* @return TRUE if the database needs upgrading, FALSE otherwise
|
||||||
*/
|
*/
|
||||||
gboolean mu_store_needs_upgrade (MuStore *store);
|
gboolean mu_store_needs_upgrade (const 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
|
||||||
|
@ -396,7 +396,7 @@ gboolean mu_store_database_is_locked (const gchar *xpath);
|
||||||
* @return a MuMsg instance (use mu_msg_unref when done with it), or
|
* @return a MuMsg instance (use mu_msg_unref when done with it), or
|
||||||
* NULL in case of error
|
* NULL in case of error
|
||||||
*/
|
*/
|
||||||
MuMsg* mu_store_get_msg (MuStore *self, unsigned docid, GError **err)
|
MuMsg* mu_store_get_msg (const MuStore *self, unsigned docid, GError **err)
|
||||||
G_GNUC_WARN_UNUSED_RESULT;
|
G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue