* enforce that maildir paths are absolute

This commit is contained in:
Dirk-Jan C. Binnema
2010-02-04 23:00:34 +02:00
parent b416714622
commit 8448473732
4 changed files with 23 additions and 15 deletions

View File

@ -144,12 +144,9 @@ more), \fBmu index\fR will terminate immediately.
.TP
\fB\-m\fR, \fB\-\-maildir\fR=\fI<maildir>\fR
starts searching at \fI<maildir>\fR. By default,
\fBmu\fR uses whatever the
.B MAILDIR
environment variable is set to; if that is not set, it tries
.B ~/Maildir
\.
starts searching at \fI<maildir>\fR. By default, \fBmu\fR uses whatever the
\fBMAILDIR\fR environment variable is set to; if that is not set, it tries
\fI~/Maildir\fR \. In either case, the path must be \fBabsolute\fR.
.TP
\fB\-r\fR, \fB\-\-reindex\fR

View File

@ -36,17 +36,17 @@ static gboolean MU_CAUGHT_SIGNAL;
static void
update_warning (void)
{
g_warning ("the database needs to be updated to version %s",
g_warning ("Note: the database needs to be updated to version %s\n",
MU_XAPIAN_DB_VERSION);
g_message ("please run 'mu index --empty' (see the manpage)");
g_warning ("please run 'mu index --empty' (see the manpage)\n");
}
static void
sig_handler (int sig)
{
if (!MU_CAUGHT_SIGNAL && sig == SIGINT) /* Ctrl-C */
g_message ("Shutting down gracefully, "
"press again to kill immediately");
g_warning ("Shutting down gracefully, "
"press again to kill immediately\n");
MU_CAUGHT_SIGNAL = TRUE;
}
@ -74,12 +74,17 @@ static gboolean
check_index_params (MuConfigOptions *opts)
{
if (opts->linksdir || opts->xquery) {
g_warning ("Invalid option(s) for command");
g_warning ("Error: Invalid option(s) for command\n");
return FALSE;
}
if (!g_path_is_absolute (opts->maildir)) {
g_warning ("Error: maildir path must be absolute\n");
return FALSE;
}
if (!mu_util_check_dir (opts->maildir, TRUE, FALSE)) {
g_message ("Please provide a valid Maildir");
g_warning ("Error: not a valid Maildir\n");
return FALSE;
}

View File

@ -222,6 +222,12 @@ static gboolean
check_path (const char* path)
{
g_return_val_if_fail (path, FALSE);
if (!g_path_is_absolute (path)) {
g_warning ("%s: not an absolute path: %s",
__FUNCTION__, path);
return FALSE;
}
if (access (path, R_OK) != 0) {
g_warning ("%s: cannot open '%s': %s",

View File

@ -90,7 +90,7 @@ typedef MuResult (*MuIndexDirCallback) (const char* path, gboolean enter,
* start the indexing process
*
* @param index a valid MuIndex instance
* @param path the path to index
* @param path the path to index. This must be an absolute path
* @param force if != 0, force re-indexing already index messages; this is
* obviously a lot slower than only indexing new/changed messages
* @param stats a structure with some statistics about the results;
@ -116,8 +116,8 @@ MuResult mu_index_run (MuIndex *index, const char* path, gboolean force,
* mu_index_run sees, when there are updates in the Maildir
*
* @param index a valid MuIndex instance
* @param path the path to get stats for
* @param stats a structure with some statistics about the results;
* @param path the path to get stats for; this must be an absolute path
* @param stats a structure with some statistics about the results;
* note that this function does *not* reset the struct values to allow
* for cumulative stats from multiple calls. If needed, you can use
* @mu_index_stats_clear before calling this function