* mu-index: take a MuStore rather than paths as arg
This commit is contained in:
@ -47,34 +47,27 @@ struct _MuIndex {
|
|||||||
};
|
};
|
||||||
|
|
||||||
MuIndex*
|
MuIndex*
|
||||||
mu_index_new (const char *xpath, const char* contacts_cache, GError **err)
|
mu_index_new (MuStore *store, GError **err)
|
||||||
{
|
{
|
||||||
MuIndex *index;
|
MuIndex *index;
|
||||||
|
|
||||||
g_return_val_if_fail (xpath, NULL);
|
g_return_val_if_fail (store, NULL);
|
||||||
|
g_return_val_if_fail (!mu_store_is_read_only(store), NULL);
|
||||||
|
|
||||||
index = g_new0 (MuIndex, 1);
|
index = g_new0 (MuIndex, 1);
|
||||||
|
|
||||||
index->_store = mu_store_new_writable (xpath, contacts_cache, err);
|
index->_store = mu_store_ref (store);
|
||||||
if (!index->_store) {
|
|
||||||
g_warning ("%s: failed to open xapian store (%s)",
|
|
||||||
__FUNCTION__, xpath);
|
|
||||||
g_free (index);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set the default max file size */
|
/* set the default max file size */
|
||||||
index->_max_filesize = MU_INDEX_MAX_FILE_SIZE;
|
index->_max_filesize = MU_INDEX_MAX_FILE_SIZE;
|
||||||
|
|
||||||
/* see we need to reindex the database; note, there is a small
|
if (mu_store_count (store) == 0)
|
||||||
* race-condition here, between mu_index_new and
|
|
||||||
* mu_index_run. Maybe do the check in mu_index_run
|
|
||||||
* instead? */
|
|
||||||
if (mu_store_database_is_empty (xpath))
|
|
||||||
index->_needs_reindex = FALSE;
|
index->_needs_reindex = FALSE;
|
||||||
else
|
|
||||||
index->_needs_reindex =
|
/* FIXME */
|
||||||
mu_store_database_needs_upgrade (xpath);
|
/* else */
|
||||||
|
/* index->_needs_reindex = */
|
||||||
|
/* mu_store_database_needs_upgrade (xpath); */
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
@ -86,8 +79,7 @@ mu_index_destroy (MuIndex *index)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
g_free (index->_last_used_maildir);
|
g_free (index->_last_used_maildir);
|
||||||
mu_store_destroy (index->_store);
|
mu_store_unref (index->_store);
|
||||||
|
|
||||||
g_free (index);
|
g_free (index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <mu-util.h> /* for MuResult */
|
#include <mu-util.h> /* for MuResult */
|
||||||
|
#include <mu-store.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -46,16 +47,13 @@ typedef struct _MuIndexStats MuIndexStats;
|
|||||||
* doing anything with the returned Index object, make sure you haved
|
* doing anything with the returned Index object, make sure you haved
|
||||||
* called g_type_init, and mu_msg_init somewhere in your code.
|
* called g_type_init, and mu_msg_init somewhere in your code.
|
||||||
*
|
*
|
||||||
* @param xpath path to the 'homedir'; the xapian directory will be
|
* @param store a writable MuStore object
|
||||||
* this homedir/xapian
|
|
||||||
* @param contacts_cache file to store the cache of contacts, or NULL
|
|
||||||
* @param err to receive error or NULL; there are only errors when this
|
* @param err to receive error or NULL; there are only errors when this
|
||||||
* function returns NULL. Possible errors: see mu-error.h
|
* function returns NULL. Possible errors: see mu-error.h
|
||||||
*
|
*
|
||||||
* @return a new MuIndex instance, or NULL in case of error
|
* @return a new MuIndex instance, or NULL in case of error
|
||||||
*/
|
*/
|
||||||
MuIndex* mu_index_new (const char* muhome, const char* contacts_cache,
|
MuIndex* mu_index_new (MuStore *store, GError **err)
|
||||||
GError **err)
|
|
||||||
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user