* mu-cmd-extract.c: only check for writability of targetdir if we're actually

going to write something; this fixes running unit tests in a unwritable env
This commit is contained in:
Dirk-Jan C. Binnema 2011-01-31 09:13:26 +02:00
parent 354cc421ea
commit 5997973d41
1 changed files with 10 additions and 10 deletions

View File

@ -188,7 +188,7 @@ save_parts (const char *path, MuConfig *opts)
MuMsg* msg;
gboolean rv;
GError *err;
err = NULL;
msg = mu_msg_new (path, NULL, &err);
if (!msg) {
@ -261,12 +261,6 @@ check_params (MuConfig *opts)
g_warning ("usage: mu extract [options] <file>");
return FALSE;
}
if (!mu_util_check_dir(opts->targetdir, FALSE, TRUE)) {
g_warning ("target '%s' is not a writable directory",
opts->targetdir);
return FALSE;
}
if (opts->save_attachments && opts->save_all) {
g_warning ("only one of --save-attachments and"
@ -299,8 +293,14 @@ mu_cmd_extract (MuConfig *opts)
!opts->save_attachments &&
!opts->save_all) /* show, don't save */
rv = show_parts (opts->params[1], opts);
else
rv = save_parts (opts->params[1], opts); /* save */
else {
rv = mu_util_check_dir(opts->targetdir, FALSE, TRUE);
if (!rv)
g_warning ("target '%s' is not a writable directory",
opts->targetdir);
else
rv = save_parts (opts->params[1], opts); /* save */
}
return rv ? MU_EXITCODE_OK : MU_EXITCODE_ERROR;
}