* use GError in various mu_maildir function to return error info

This commit is contained in:
Dirk-Jan C. Binnema
2010-12-05 16:29:53 +02:00
parent 8b70e6bace
commit 68af173246
6 changed files with 100 additions and 57 deletions

View File

@ -40,22 +40,34 @@
gboolean
mu_output_link_create_dir (const char *linksdir, gboolean clearlinks)
{
g_return_val_if_fail (linksdir, FALSE);
GError *err;
g_return_val_if_fail (linksdir, FALSE);
if (access (linksdir, F_OK) != 0) {
if (!mu_maildir_mkmdir (linksdir, 0700, TRUE))
return FALSE;
} else if (clearlinks)
mu_maildir_clear_links (linksdir);
return TRUE;
err = NULL;
if (access (linksdir, F_OK) != 0) {
if (!mu_maildir_mkdir (linksdir, 0700, TRUE, &err))
goto fail;
} else if (clearlinks)
if (!mu_maildir_clear_links (linksdir, &err))
goto fail;
return TRUE;
fail:
if (err) {
g_warning ("%s", err->message ? err->message : "unknown error");
g_error_free (err);
}
return FALSE;
}
gboolean
mu_output_link_row (MuMsgIter *iter, const char* linksdir)
{
const char *path;
GError *err;
g_return_val_if_fail (iter, FALSE);
g_return_val_if_fail (linksdir, FALSE);
@ -63,21 +75,27 @@ mu_output_link_row (MuMsgIter *iter, const char* linksdir)
path = mu_msg_iter_get_field (iter, MU_MSG_FIELD_ID_PATH);
if (!path)
return FALSE;
return FALSE;
/* this might happen if the database is not up-to-date, not an error */
if (access (path, R_OK) != 0) {
if (errno == ENOENT)
g_warning ("cannot find source message %s: "
"the database is not up-to-date", path);
if (errno == ENOENT)
g_warning ("cannot find source message %s: "
"the database is not up-to-date", path);
else
g_warning ("cannot read source message %s: %s", path,
strerror (errno));
return FALSE;
}
if (!mu_maildir_link (path, linksdir))
return FALSE;
err = NULL;
if (!mu_maildir_link (path, linksdir, &err)) {
if (err) {
g_warning ("%s", err->message ? err->message : "unknown error");
g_error_free (err);
}
return FALSE;
}
return TRUE;
}