]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/askdir.c
Suppress some error messages generated after cancelling a job
[bacula/bacula] / bacula / src / stored / askdir.c
index 4d33c255ae8c2bc074d29f8d1256dc62ef9ecca5..b85d78e6ebbba8b90cac1caebc0f4eb8037b7053 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2009 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.
@@ -281,7 +281,7 @@ bool dir_find_next_appendable_volume(DCR *dcr)
              break;
           }
           bstrncpy(lastVolume, dcr->VolumeName, sizeof(lastVolume));
-          if (dcr->can_i_use_volume()) {
+          if (dcr->can_i_write_volume()) {
              Dmsg1(100, "Call reserve_volume. Vol=%s\n", dcr->VolumeName);
              if (reserve_volume(dcr, dcr->VolumeName) == NULL) {
                 Dmsg2(100, "Could not reserve volume %s on %s\n", dcr->VolumeName,
@@ -387,7 +387,7 @@ bail_out:
 /*
  * After writing a Volume, create the JobMedia record.
  */
-bool dir_create_jobmedia_record(DCR *dcr)
+bool dir_create_jobmedia_record(DCR *dcr, bool zero)
 {
    JCR *jcr = dcr->jcr;
    BSOCK *dir = jcr->dir_bsock;
@@ -398,17 +398,30 @@ bool dir_create_jobmedia_record(DCR *dcr)
       return true;
    }
 
+   /* Throw out records where FI is zero -- i.e. nothing done */
+   if (!zero && dcr->VolFirstIndex == 0 && 
+        (dcr->StartBlock != 0 || dcr->EndBlock != 0)) {
+      Dmsg0(100, "JobMedia FI=0 StartBlock!=0 record suppressed\n");
+      return true;
+   }
+
    if (!dcr->WroteVol) {
       return true;                    /* nothing written to tape */
    }
 
    dcr->WroteVol = false;
-   dir->fsend(Create_job_media, jcr->Job,
-      dcr->VolFirstIndex, dcr->VolLastIndex,
-      dcr->StartFile, dcr->EndFile,
-      dcr->StartBlock, dcr->EndBlock, 
-      dcr->Copy, dcr->Stripe, 
-      edit_uint64(dcr->VolMediaId, ed1));
+   if (zero) {
+      /* Send dummy place holder to avoid purging */
+      dir->fsend(Create_job_media, jcr->Job,
+         0 , 0, 0, 0, 0, 0, 0, 0, edit_uint64(dcr->VolMediaId, ed1));
+   } else {
+      dir->fsend(Create_job_media, jcr->Job,
+         dcr->VolFirstIndex, dcr->VolLastIndex,
+         dcr->StartFile, dcr->EndFile,
+         dcr->StartBlock, dcr->EndBlock, 
+         dcr->Copy, dcr->Stripe, 
+         edit_uint64(dcr->VolMediaId, ed1));
+   }
    Dmsg1(100, ">dird %s", dir->msg);
    if (dir->recv() <= 0) {
       Dmsg0(190, "create_jobmedia error bnet_recv\n");
@@ -452,6 +465,10 @@ bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec)
    ser_bytes(rec->data, rec->data_len);
    dir->msglen = ser_length(dir->msg);
    Dmsg1(1800, ">dird %s\n", dir->msg);    /* Attributes */
+   if (rec->Stream == STREAM_UNIX_ATTRIBUTES || 
+       rec->Stream == STREAM_UNIX_ATTRIBUTES_EX) {
+      dir->set_data_end();                 /* set offset of last valid data */
+   }
    return dir->send();
 }
 
@@ -481,6 +498,9 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr)
    JCR *jcr = dcr->jcr;
    bool got_vol = false;
 
+   if (job_canceled(jcr)) {
+      return false;
+   }
    Dmsg0(400, "enter dir_ask_sysop_to_create_appendable_volume\n");
    ASSERT(dev->blocked());
    for ( ;; ) {