]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/catreq.c
kes Close bat console windows first to eliminate error message
[bacula/bacula] / bacula / src / dird / catreq.c
index cc1903615f8ea585503b65f9d0e8d53060a7150b..224d5e7e2b59d6b60a6412df36d0edf1a903005f 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2001-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2001-2008 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.
@@ -266,6 +266,11 @@ void catalog_request(JCR *jcr, BSOCK *bs)
          }
       }
       Dmsg2(400, "Update media: BefVolJobs=%u After=%u\n", mr.VolJobs, sdmr.VolJobs);
+      /* Check if the volume has been written by the job, 
+       * and update the LastWritten field if needed */
+      if (mr.VolBlocks != sdmr.VolBlocks) {
+         mr.LastWritten = sdmr.LastWritten;
+      }
       /* Copy updated values to original media record */
       mr.VolJobs      = sdmr.VolJobs;
       mr.VolFiles     = sdmr.VolFiles;
@@ -274,14 +279,18 @@ void catalog_request(JCR *jcr, BSOCK *bs)
       mr.VolMounts    = sdmr.VolMounts;
       mr.VolErrors    = sdmr.VolErrors;
       mr.VolWrites    = sdmr.VolWrites;
-      mr.LastWritten  = sdmr.LastWritten;
       mr.Slot         = sdmr.Slot;
       mr.InChanger    = sdmr.InChanger;
       mr.VolReadTime  = sdmr.VolReadTime;
       mr.VolWriteTime = sdmr.VolWriteTime;
       mr.VolParts     = sdmr.VolParts;
       bstrncpy(mr.VolStatus, sdmr.VolStatus, sizeof(mr.VolStatus));
-      if (jcr->wstore && jcr->wstore->StorageId) {
+      /*
+       * Update to point to the last device used to write the Volume.
+       *   However, do so only if we are writing the tape, i.e.
+       *   the number of VolBlocks has increased.
+       */
+      if (jcr->wstore && jcr->wstore->StorageId && mr.VolBlocks != sdmr.VolBlocks) {
          mr.StorageId = jcr->wstore->StorageId;
       }
 
@@ -319,7 +328,7 @@ void catalog_request(JCR *jcr, BSOCK *bs)
       if (!db_create_jobmedia_record(jcr, jcr->db, &jm)) {
          Jmsg(jcr, M_FATAL, 0, _("Catalog error creating JobMedia record. %s"),
             db_strerror(jcr->db));
-         bs->fsend(_("1991 Update JobMedia error\n"));
+         bs->fsend(_("1992 Create JobMedia error\n"));
       } else {
          Dmsg0(400, "JobMedia record created\n");
          bs->fsend(OK_create);
@@ -364,7 +373,7 @@ void catalog_update(JCR *jcr, BSOCK *bs)
    if (!jcr->db) {
       omsg = get_memory(bs->msglen+1);
       pm_strcpy(omsg, bs->msg);
-      bs->fsend(_("1991 Invalid Catalog Update: %s"), omsg);    
+      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;