mirror of https://github.com/djcb/mu.git
* mu-index.[ch]: take the mu-dir as parameter for mu_index_new
the xapian dir is a subdir of this one. Also remove an unneeded function decl
This commit is contained in:
parent
05c0acb900
commit
ef553bef06
|
@ -32,33 +32,36 @@
|
||||||
#include "mu-index.h"
|
#include "mu-index.h"
|
||||||
#include "mu-store-xapian.h"
|
#include "mu-store-xapian.h"
|
||||||
|
|
||||||
|
#define MU_XAPIAN_DIR_NAME "xapian"
|
||||||
|
|
||||||
|
|
||||||
struct _MuIndex {
|
struct _MuIndex {
|
||||||
MuStoreXapian *_xapian;
|
MuStoreXapian *_xapian;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
MuIndex*
|
MuIndex*
|
||||||
mu_index_new (const char *xpath)
|
mu_index_new (const char *muhome)
|
||||||
{
|
{
|
||||||
MuIndex *index;
|
MuIndex *index;
|
||||||
|
char *xpath;
|
||||||
|
|
||||||
g_return_val_if_fail (xpath, NULL);
|
g_return_val_if_fail (muhome, NULL);
|
||||||
|
|
||||||
do {
|
index = g_new0 (MuIndex, 1);
|
||||||
index = g_new0 (MuIndex, 1);
|
xpath = g_strdup_printf ("%s%c%s", muhome,
|
||||||
index->_xapian = mu_store_xapian_new (xpath);
|
G_DIR_SEPARATOR, MU_XAPIAN_DIR_NAME);
|
||||||
if (!index->_xapian) {
|
index->_xapian = mu_store_xapian_new (xpath);
|
||||||
g_warning ("%s: failed to get xapian store (%s)",
|
g_free (xpath);
|
||||||
__FUNCTION__, xpath);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return index;
|
|
||||||
|
|
||||||
} while (0);
|
if (!index->_xapian) {
|
||||||
|
g_warning ("%s: failed to open xapian store (%s)",
|
||||||
|
__FUNCTION__, muhome);
|
||||||
|
g_free (index);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
mu_index_destroy (index);
|
return index;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,12 +191,6 @@ check_path (const char* path)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (path, FALSE);
|
g_return_val_if_fail (path, FALSE);
|
||||||
|
|
||||||
if (!g_path_is_absolute (path)) {
|
|
||||||
g_warning ("%s: path is not absolute '%s'",
|
|
||||||
__FUNCTION__, path);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (access (path, R_OK) != 0) {
|
if (access (path, R_OK) != 0) {
|
||||||
g_warning ("%s: cannot open '%s': %s",
|
g_warning ("%s: cannot open '%s': %s",
|
||||||
__FUNCTION__, path, strerror (errno));
|
__FUNCTION__, path, strerror (errno));
|
||||||
|
|
|
@ -43,11 +43,12 @@ typedef struct _MuIndexStats MuIndexStats;
|
||||||
* make sure you haved called g_type_init, and mu_msg_init somewhere
|
* make sure you haved called g_type_init, and mu_msg_init somewhere
|
||||||
* in your code.
|
* in your code.
|
||||||
*
|
*
|
||||||
* @param xpath path to the xapian db to store the results
|
* @param xpath path to the 'homedir'; the xapian directory will be
|
||||||
|
* this homedir/xapian
|
||||||
*
|
*
|
||||||
* @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* xpath);
|
MuIndex* mu_index_new (const char* muhome);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,12 +143,4 @@ MuResult mu_index_cleanup (MuIndex *index, MuIndexStats *result,
|
||||||
MuIndexMsgCallback msg_cb, MuIndexDirCallback dir_cb,
|
MuIndexMsgCallback msg_cb, MuIndexDirCallback dir_cb,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get the option group for 'index'
|
|
||||||
*
|
|
||||||
* @return an option group
|
|
||||||
*/
|
|
||||||
GOptionGroup* mu_index_option_group (void);
|
|
||||||
|
|
||||||
#endif /*__MU_INDEX_H__*/
|
#endif /*__MU_INDEX_H__*/
|
||||||
|
|
Loading…
Reference in New Issue