* mu-util.h, mu-util-db.cc: make mu_util_xapian_clear also clear the contacts-cache
This commit is contained in:
@ -99,16 +99,30 @@ mu_util_xapian_is_empty (const gchar* xpath)
|
||||
}
|
||||
|
||||
gboolean
|
||||
mu_util_xapian_clear (const gchar *xpath)
|
||||
mu_util_xapian_clear (const gchar *xpath,
|
||||
const char *ccache)
|
||||
{
|
||||
g_return_val_if_fail (xpath, FALSE);
|
||||
g_return_val_if_fail (ccache, FALSE);
|
||||
|
||||
try {
|
||||
int rv;
|
||||
|
||||
/* clear the database */
|
||||
Xapian::WritableDatabase db
|
||||
(xpath, Xapian::DB_CREATE_OR_OVERWRITE);
|
||||
db.flush ();
|
||||
|
||||
MU_WRITE_LOG ("emptied database %s", xpath);
|
||||
|
||||
/* clear the contacts cache; this is not totally
|
||||
* fail-safe, as some other process may still have it
|
||||
* open... */
|
||||
rv = unlink (ccache);
|
||||
if (rv != 0 && errno != ENOENT) {
|
||||
g_warning ("failed to remove contacts-cache: %s",
|
||||
strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
|
||||
@ -184,13 +184,15 @@ gboolean mu_util_xapian_is_empty (const gchar *xpath);
|
||||
/**
|
||||
* clear the database, ie., remove all of the contents. This is a
|
||||
* destructive operation, but the database can be restored be doing a
|
||||
* full scan of the maildirs.
|
||||
* full scan of the maildirs. Also, clear the contacts cache file
|
||||
*
|
||||
* @param xpath path to the database
|
||||
* @param ccache path to the contacts cache file
|
||||
*
|
||||
* @return TRUE if the clearing succeeded, FALSE otherwise.
|
||||
*/
|
||||
gboolean mu_util_xapian_clear (const gchar *xpath);
|
||||
gboolean mu_util_xapian_clear (const gchar *xpath,
|
||||
const gchar *ccache);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user