]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/catreq.c
Ignore unknown dot commands in restore tree code
[bacula/bacula] / bacula / src / dird / catreq.c
index 00af56fa38d25241265fab2d47e41aaf2fe9228e..d452f9913cfcb5281af96a091981e8b655c67275 100644 (file)
@@ -1,12 +1,12 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2001-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2001-2010 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.
@@ -37,7 +37,6 @@
  *  Basic tasks done here:
  *      Handle Catalog services.
  *
- *   Version $Id$
  */
 
 #include "bacula.h"
@@ -110,7 +109,7 @@ void catalog_request(JCR *jcr, BSOCK *bs)
    int index, ok, label, writing;
    POOLMEM *omsg;
    POOL_DBR pr;
-   uint32_t Stripe;
+   uint32_t Stripe, Copy;
    uint64_t MediaId;
    utime_t VolFirstWritten;
    utime_t VolLastWritten;
@@ -283,7 +282,13 @@ void catalog_request(JCR *jcr, BSOCK *bs)
        *   the number of VolWrites has increased.
        */
       if (jcr->wstore && jcr->wstore->StorageId && sdmr.VolWrites > mr.VolWrites) {
-         mr.StorageId = jcr->wstore->StorageId;
+         Dmsg2(050, "Update StorageId old=%d new=%d\n",
+               mr.StorageId, jcr->wstore->StorageId);
+         if (jcr->wstore->StorageId == 0) {
+            Jmsg(jcr, M_ERROR, 0, _("Attempt to set StorageId to zero.\n"));
+         } else {
+            mr.StorageId = jcr->wstore->StorageId;
+         }
       }
 
       /* Copy updated values to original media record */
@@ -326,7 +331,7 @@ void catalog_request(JCR *jcr, BSOCK *bs)
     */
    } else if (sscanf(bs->msg, Create_job_media, &Job,
       &jm.FirstIndex, &jm.LastIndex, &jm.StartFile, &jm.EndFile,
-      &jm.StartBlock, &jm.EndBlock, &jm.Copy, &Stripe, &MediaId) == 10) {
+      &jm.StartBlock, &jm.EndBlock, &Copy, &Stripe, &MediaId) == 10) {
 
       if (jcr->mig_jcr) {
          jm.JobId = jcr->mig_jcr->JobId;
@@ -508,21 +513,20 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen)
  */
 void catalog_update(JCR *jcr, BSOCK *bs)
 {
-   POOLMEM *omsg;
-
-   if (job_canceled(jcr) || !jcr->pool->catalog_files) {
-      goto bail_out;                  /* user disabled cataloging */
+   if (!jcr->pool->catalog_files) {
+      return;                         /* user disabled cataloging */
+   }
+   if (job_canceled(jcr)) {
+      goto bail_out;
    }
    if (!jcr->db) {
-      omsg = get_memory(bs->msglen+1);
+      POOLMEM *omsg = get_memory(bs->msglen+1);
       pm_strcpy(omsg, bs->msg);
       bs->fsend(_("1994 Invalid Catalog Update: %s"), omsg);    
       Jmsg1(jcr, M_FATAL, 0, _("Invalid Catalog Update; DB not open: %s"), omsg);
       free_memory(omsg);
       goto bail_out;
-
    }
-
    update_attribute(jcr, bs->msg, bs->msglen);
 
 bail_out:
@@ -584,7 +588,12 @@ bool despool_attributes_from_file(JCR *jcr, const char *file)
             last = size;
          }
       }
-      update_attribute(jcr, msg, msglen);
+      if (!job_canceled(jcr)) {
+         update_attribute(jcr, msg, msglen);
+         if (job_canceled(jcr)) {
+            goto bail_out;
+         }
+      }
    }
    if (ferror(spool_fd)) {
       berrno be;