mirror of https://github.com/djcb/mu.git
* mu-cmd: fix error in links while-loop, some cleanups
This commit is contained in:
parent
7b01eea5e7
commit
95bb6f9756
27
src/mu-cmd.c
27
src/mu-cmd.c
|
@ -167,9 +167,11 @@ _print_rows (MuQueryXapian *xapian, const gchar *query, MuConfigOptions *opts)
|
||||||
do {
|
do {
|
||||||
const char* fields = opts->fields;
|
const char* fields = opts->fields;
|
||||||
int printlen = 0;
|
int printlen = 0;
|
||||||
|
|
||||||
while (*fields) {
|
while (*fields) {
|
||||||
const MuMsgField* field =
|
|
||||||
mu_msg_field_from_shortcut (*fields);
|
const MuMsgField* field;
|
||||||
|
field = mu_msg_field_from_shortcut (*fields);
|
||||||
if (!field ||
|
if (!field ||
|
||||||
!mu_msg_field_is_xapian_enabled (field))
|
!mu_msg_field_is_xapian_enabled (field))
|
||||||
printlen += printf ("%c", *fields);
|
printlen += printf ("%c", *fields);
|
||||||
|
@ -177,7 +179,8 @@ _print_rows (MuQueryXapian *xapian, const gchar *query, MuConfigOptions *opts)
|
||||||
printlen += printf ("%s",
|
printlen += printf ("%s",
|
||||||
_display_field(row, field));
|
_display_field(row, field));
|
||||||
++fields;
|
++fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (printlen > 0)
|
if (printlen > 0)
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
|
|
||||||
|
@ -186,6 +189,7 @@ _print_rows (MuQueryXapian *xapian, const gchar *query, MuConfigOptions *opts)
|
||||||
} while (!mu_msg_xapian_is_done (row));
|
} while (!mu_msg_xapian_is_done (row));
|
||||||
|
|
||||||
mu_msg_xapian_destroy (row);
|
mu_msg_xapian_destroy (row);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,8 +222,10 @@ static gboolean
|
||||||
_create_or_clear_linksdir_maybe (MuConfigOptions* opts)
|
_create_or_clear_linksdir_maybe (MuConfigOptions* opts)
|
||||||
{
|
{
|
||||||
if (access (opts->linksdir, F_OK) != 0) {
|
if (access (opts->linksdir, F_OK) != 0) {
|
||||||
|
|
||||||
if (!mu_maildir_mkmdir (opts->linksdir, 0700, TRUE))
|
if (!mu_maildir_mkmdir (opts->linksdir, 0700, TRUE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
} else if (opts->clearlinks)
|
} else if (opts->clearlinks)
|
||||||
mu_maildir_clear_links (opts->linksdir);
|
mu_maildir_clear_links (opts->linksdir);
|
||||||
|
|
||||||
|
@ -254,9 +260,11 @@ _do_output_links (MuQueryXapian *xapian, MuConfigOptions* opts,
|
||||||
pathfield = mu_msg_field_from_id (MU_MSG_FIELD_ID_PATH);
|
pathfield = mu_msg_field_from_id (MU_MSG_FIELD_ID_PATH);
|
||||||
|
|
||||||
/* iterate over the found rows */
|
/* iterate over the found rows */
|
||||||
do {
|
for (; !mu_msg_xapian_is_done (row); mu_msg_xapian_next (row)) {
|
||||||
const char *path =
|
|
||||||
mu_msg_xapian_get_field (row, pathfield);
|
const char *path;
|
||||||
|
|
||||||
|
path = mu_msg_xapian_get_field (row, pathfield);
|
||||||
if (!path)
|
if (!path)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -265,14 +273,11 @@ _do_output_links (MuQueryXapian *xapian, MuConfigOptions* opts,
|
||||||
g_warning ("Cannot read source message %s: %s",
|
g_warning ("Cannot read source message %s: %s",
|
||||||
path, strerror (errno));
|
path, strerror (errno));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mu_maildir_link (path, opts->linksdir))
|
if (!mu_maildir_link (path, opts->linksdir))
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
mu_msg_xapian_next (row);
|
|
||||||
|
|
||||||
} while (!mu_msg_xapian_is_done (row));
|
|
||||||
|
|
||||||
mu_msg_xapian_destroy (row);
|
mu_msg_xapian_destroy (row);
|
||||||
g_free (query);
|
g_free (query);
|
||||||
|
|
Loading…
Reference in New Issue