]> git.sur5r.net Git - bacula/bacula/commitdiff
Ensure that zero JobMedias are written for labelling
authorKern Sibbald <kern@sibbald.com>
Mon, 11 Jul 2016 08:43:50 +0000 (10:43 +0200)
committerKern Sibbald <kern@sibbald.com>
Tue, 20 Sep 2016 15:13:49 +0000 (17:13 +0200)
Conflicts:
bacula/src/stored/askdir.c

bacula/src/stored/askdir.c
bacula/src/stored/block_util.c

index d60ae101a7ccd75563626762b039842c2e6d609f..af0da08ca176d702ee16ec4e7d15a89ae4cc3364 100644 (file)
@@ -520,17 +520,17 @@ bool dir_create_jobmedia_record(DCR *dcr, bool zero)
    JOBMEDIA_ITEM *item;
    bool ok = true;;
 
-   if (!dcr->WroteVol) {
+   if (!zero && !dcr->WroteVol) {
       return true;
    }
-   if (dcr->VolLastIndex == 0) {
+   if (!zero && dcr->VolLastIndex == 0) {
       Dmsg7(dbglvl, "JobMedia Vol=%s wrote=%d MediaId=%d FI=%d LI=%d StartBlock=%d EndBlock=%d Suppressed\n",
          dcr->VolumeName, dcr->WroteVol, dcr->VolMediaId,
          dcr->VolFirstIndex, dcr->VolLastIndex, dcr->StartBlock, dcr->EndBlock);
       return true;                    /* nothing written to the Volume */
    }
-   if (dcr->StartFile == dcr->EndFile && dcr->EndBlock < dcr->StartBlock) {
-      Dmsg7(0/*dbglvl*/, "PROBLEM Vol=%s wrote=%d MediaId=%d FI=%d LI=%d StartBlock=%d EndBlock=%d Suppressed\n",
+   if (!zero && dcr->StartFile == dcr->EndFile && dcr->EndBlock < dcr->StartBlock) {
+      Dmsg7(dbglvl, "JobMedia Vol=%s wrote=%d MediaId=%d FI=%d LI=%d StartBlock=%d EndBlock=%d Suppressed\n",
          dcr->VolumeName, dcr->WroteVol, dcr->VolMediaId,
          dcr->VolFirstIndex, dcr->VolLastIndex, dcr->StartBlock, dcr->EndBlock);
       return true;
index cedcc8d33518b349d36fcf63a5a86a8027c5b990..3d67de92086f20bf44cebdb85c22701dcb2c32ff 100644 (file)
@@ -621,8 +621,8 @@ bool check_for_newvol_or_newfile(DCR *dcr)
          Dmsg0(100, "Canceled\n");
          return false;
       }
-      /* Create a jobmedia record for this job */
-      if (!dir_create_jobmedia_record(dcr)) {
+      /* If we wrote on Volume create a last jobmedia record for this job */
+      if (dcr->VolFirstIndex && !dir_create_jobmedia_record(dcr)) {
          dcr->dev->dev_errno = EIO;
          Jmsg2(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
             dcr->getVolCatName(), jcr->Job);