* mu-index: take a MuStore rather than paths as arg

This commit is contained in:
Dirk-Jan C. Binnema
2011-08-30 22:00:52 +03:00
parent 1c4016b1ba
commit c1d0ccc8de
2 changed files with 49 additions and 59 deletions

View File

@ -47,34 +47,27 @@ struct _MuIndex {
};
MuIndex*
mu_index_new (const char *xpath, const char* contacts_cache, GError **err)
mu_index_new (MuStore *store, GError **err)
{
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->_store = mu_store_new_writable (xpath, contacts_cache, err);
if (!index->_store) {
g_warning ("%s: failed to open xapian store (%s)",
__FUNCTION__, xpath);
g_free (index);
return NULL;
}
index->_store = mu_store_ref (store);
/* set the default max file size */
index->_max_filesize = MU_INDEX_MAX_FILE_SIZE;
/* see we need to reindex the database; note, there is a small
* 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))
if (mu_store_count (store) == 0)
index->_needs_reindex = FALSE;
else
index->_needs_reindex =
mu_store_database_needs_upgrade (xpath);
/* FIXME */
/* else */
/* index->_needs_reindex = */
/* mu_store_database_needs_upgrade (xpath); */
return index;
}
@ -86,8 +79,7 @@ mu_index_destroy (MuIndex *index)
return;
g_free (index->_last_used_maildir);
mu_store_destroy (index->_store);
mu_store_unref (index->_store);
g_free (index);
}