From 5b3150fb71045b20188b262948a0e3ad95b5d429 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Sat, 4 May 2013 13:14:58 +0200 Subject: [PATCH] For migration/copy Jobs need to look at mig_jcr. Added new %V option to expansion variables which is the same as %v but always prints the destination Volumes a Job used. For migration and copy Jobs this expansion looks at the mig_jcr pointer in the JCR. As this mig_jcr only exists in the director the %V is expanded in the callback expansion function in the director as in the generic expansion function is compiled as part of the generic shared library we are missing that variable there. While implementing this expansion also reformated the whole function as the switch statement was wrongly indented. Removed unneeded break statements after a return. Document what is expanded in the callback expansion function. Fixes #139: export command in a RunScript ressource does not get the correct volume when doing scheduled JobType Copy --- src/dird/dird_conf.c | 79 +++++++++++++++++++++++++++++--------------- src/lib/util.c | 7 ++-- 2 files changed, 55 insertions(+), 31 deletions(-) diff --git a/src/dird/dird_conf.c b/src/dird/dird_conf.c index 3a038728235..56b41682d9d 100644 --- a/src/dird/dird_conf.c +++ b/src/dird/dird_conf.c @@ -2393,42 +2393,67 @@ static void store_runscript(LEX *lc, RES_ITEM *item, int index, int pass) /* * callback function for edit_job_codes * See ../lib/util.c, function edit_job_codes, for more remaining codes + * + * %f = Filesetname + * %h = Client Address + * %p = Poolname + * %w = Write storage + * %x = Spooling (yes/no) + * %C = Cloning (yes/no) + * %D = Director name + * %V = Volume name(s) (Destination) */ extern "C" char *job_code_callback_director(JCR *jcr, const char *param) { static char yes[] = "yes"; static char no[] = "no"; switch (param[0]) { - case 'f': - if (jcr->res.fileset) { - return jcr->res.fileset->name(); - } - break; - case 'h': - if (jcr->res.client) { - return jcr->res.client->address; - } - break; - case 'p': - if (jcr->res.pool) { - return jcr->res.pool->name(); + case 'f': + if (jcr->res.fileset) { + return jcr->res.fileset->name(); + } + break; + case 'h': + if (jcr->res.client) { + return jcr->res.client->address; + } + break; + case 'p': + if (jcr->res.pool) { + return jcr->res.pool->name(); + } + break; + case 'w': + if (jcr->res.wstore) { + return jcr->res.wstore->name(); + } + break; + case 'x': + return jcr->spool_data ? yes : no; + case 'C': + return jcr->cloned ? yes : no; + case 'D': + return my_name; + case 'V': + if (jcr) { + /* + * If this is a migration/copy we need the volume name from the mig_jcr. + */ + if (jcr->mig_jcr) { + jcr = jcr->mig_jcr; } - break; - case 'w': - if (jcr->res.wstore) { - return jcr->res.wstore->name(); + + if (jcr->VolumeName) { + return jcr->VolumeName; + } else { + return _("*none*"); } - break; - case 'x': - return jcr->spool_data ? yes : no; - break; - case 'D': - return my_name; - break; - case 'C': - return jcr->cloned ? yes : no; - break; + } else { + return _("*none*"); + } + break; } + return NULL; } diff --git a/src/lib/util.c b/src/lib/util.c index 26b609aee2d..4e62a83860f 100644 --- a/src/lib/util.c +++ b/src/lib/util.c @@ -711,12 +711,11 @@ void decode_session_key(char *decode, char *session, char *key, int maxlen) * %s = Since time * %t = Job type (Backup, ...) * %r = Recipients - * %v = Volume name + * %v = Volume name(s) * * omsg = edited output message * imsg = input string containing edit codes (%x) * to = recepients list - * */ POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to, job_code_callback_t callback) { @@ -818,10 +817,10 @@ POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to, job_co break; case 'v': if (jcr) { - if (jcr->VolumeName && jcr->VolumeName[0]) { + if (jcr->VolumeName) { str = jcr->VolumeName; } else { - str = ""; + str = _("*none*"); } } else { str = _("*none*");