From 5997973d415944d2c7b983e1f272859eaaa0f093 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Mon, 31 Jan 2011 09:13:26 +0200 Subject: [PATCH] * 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 --- src/mu-cmd-extract.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mu-cmd-extract.c b/src/mu-cmd-extract.c index 82e32896..bb35a542 100644 --- a/src/mu-cmd-extract.c +++ b/src/mu-cmd-extract.c @@ -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] "); 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; }