]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/pythondir.c
Ensure that StorageId is updated after write
[bacula/bacula] / bacula / src / dird / pythondir.c
index a0160435a8eea9c22ec216ed8e067c25b55f835e..1782e7fae401e01d26698c081117b7fac8b11c0a 100644 (file)
@@ -1,12 +1,12 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2004-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2004-2012 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -31,7 +31,6 @@
  *
  * Kern Sibbald, November MMIV
  *
- *   Version $Id$
  *
  */
 
@@ -136,9 +135,9 @@ PyObject *job_getattr(PyObject *self, char *attrname)
    case 0:                            /* Job */
       return Py_BuildValue((char *)getvars[i].fmt, jcr->job->hdr.name);
    case 1:                            /* level */
-      return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->get_JobLevel()));
+      return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->getJobLevel()));
    case 2:                            /* type */
-      return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->get_JobType()));
+      return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->getJobType()));
    case 3:                            /* JobId */
       return Py_BuildValue((char *)getvars[i].fmt, jcr->JobId);
    case 4:                            /* Client */
@@ -189,7 +188,7 @@ PyObject *job_getattr(PyObject *self, char *attrname)
          jcr->catalog->db_name, jcr->catalog->db_address, 
          jcr->catalog->db_user, jcr->catalog->db_password,
          jcr->catalog->db_socket, jcr->catalog->db_port,
-         db_get_type());
+         db_get_type(jcr->db));
    case 15:                           /* JobErrors */
       return Py_BuildValue((char *)getvars[i].fmt, jcr->JobErrors);
    case 16:                           /* JobFiles */
@@ -202,7 +201,7 @@ PyObject *job_getattr(PyObject *self, char *attrname)
       buf[1] = 0;
       buf[0] = jcr->FDJobStatus;
       return Py_BuildValue((char *)getvars[i].fmt, buf);
-   case 29:                           /* SDJobStatus */
+   case 20:                           /* SDJobStatus */
       buf[1] = 0;
       buf[0] = jcr->SDJobStatus;
       return Py_BuildValue((char *)getvars[i].fmt, buf);
@@ -290,12 +289,14 @@ int job_setattr(PyObject *self, char *attrname, PyObject *value)
          PyErr_SetString(PyExc_RuntimeError, _("Job Level can be set only during JobInit"));
          return -1;
       }
-      for (i=0; joblevels[i].level_name; i++) {
-         if (strcmp(strval, joblevels[i].level_name) == 0) {
-            if (joblevels[i].job_type == jcr->get_JobType()) {
-               jcr->set_JobLevel(joblevels[i].level);
-               jcr->jr.JobLevel = jcr->get_JobLevel();
-               return 0;
+      if (strval != NULL) {
+         for (i=0; joblevels[i].level_name; i++) {
+            if (strcmp(strval, joblevels[i].level_name) == 0) {
+               if (joblevels[i].job_type == jcr->getJobType()) {
+                  jcr->setJobLevel(joblevels[i].level);
+                  jcr->jr.JobLevel = jcr->getJobLevel();
+                  return 0;
+               }
             }
          }
       }
@@ -380,7 +381,6 @@ static PyObject *job_does_vol_exist(PyObject *self, PyObject *args)
       MEDIA_DBR mr;
       int ok;
       JCR *jcr = get_jcr_from_PyObject(self);
-      memset(&mr, 0, sizeof(mr));
       bstrncpy(mr.VolumeName, VolName, sizeof(mr.VolumeName));
       ok = db_get_media_record(jcr, jcr->db, &mr);
       return Py_BuildValue("i", ok);