]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/catreq.c
migrate
[bacula/bacula] / bacula / src / dird / catreq.c
index 5ac184d4f529701665be001d5717c3b37a9ac60e..8477d8bbc854ee076e5e91a843fa662aae3eece5 100644 (file)
@@ -13,7 +13,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2001-2005 Kern Sibbald
+   Copyright (C) 2001-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -122,7 +122,9 @@ void catalog_request(JCR *jcr, BSOCK *bs)
       ok = db_get_pool_record(jcr, jcr->db, &pr);
       if (ok) {
          mr.PoolId = pr.PoolId;
-         ok = find_next_volume_for_append(jcr, &mr, true /*permit create new vol*/);
+         mr.StorageId = jcr->store->StorageId;
+         ok = find_next_volume_for_append(jcr, &mr, index, true /*permit create new vol*/);
+         Dmsg3(100, "find_media idx=%d ok=%d vol=%s\n", index, ok, mr.VolumeName);
       }
       /*
        * Send Find Media response to Storage daemon
@@ -157,21 +159,11 @@ void catalog_request(JCR *jcr, BSOCK *bs)
              *   Pool matches, and it is either Append or Recycle
              *   and Media Type matches and Pool allows any volume.
              */
-            if (mr.PoolId != jcr->PoolId) {
+            if (mr.PoolId != jcr->jr.PoolId) {
                reason = _("not in Pool");
             } else if (strcmp(mr.MediaType, jcr->store->media_type) != 0) {
                reason = _("not correct MediaType");
             } else {
-              /*
-               * ****FIXME***
-               *   This test (accept_any_volume) is turned off
-               *   because it doesn't properly check if the volume
-               *   really is out of sequence!
-               *
-               * } else if (!jcr->pool->accept_any_volume) {
-               *    reason = "Volume not in sequence";
-               */
-
                /*
                 * Now try recycling if necessary
                 *   reason set non-NULL if we cannot use it
@@ -286,8 +278,13 @@ void catalog_request(JCR *jcr, BSOCK *bs)
       &jm.FirstIndex, &jm.LastIndex, &jm.StartFile, &jm.EndFile,
       &jm.StartBlock, &jm.EndBlock, &jm.Copy, &jm.Stripe) == 9) {
 
-      jm.JobId = jcr->JobId;
-      jm.MediaId = jcr->MediaId;
+      if (jcr->previous_jcr) {
+         jm.JobId = jcr->previous_jcr->JobId;
+         jm.MediaId = jcr->MediaId;
+      } else {
+         jm.JobId = jcr->JobId;
+         jm.MediaId = jcr->MediaId;
+      }
       Dmsg6(400, "create_jobmedia JobId=%d MediaId=%d SF=%d EF=%d FI=%d LI=%d\n",
          jm.JobId, jm.MediaId, jm.StartFile, jm.EndFile, jm.FirstIndex, jm.LastIndex);
       if (!db_create_jobmedia_record(jcr, jcr->db, &jm)) {
@@ -396,7 +393,11 @@ void catalog_update(JCR *jcr, BSOCK *bs)
       ar->FileIndex = FileIndex;
       ar->Stream = Stream;
       ar->link = NULL;
-      ar->JobId = jcr->JobId;
+      if (jcr->previous_jcr) {
+         ar->JobId = jcr->previous_jcr->JobId;
+      } else {
+         ar->JobId = jcr->JobId;
+      }
       ar->Digest = NULL;
       ar->DigestType = CRYPTO_DIGEST_NONE;
       jcr->cached_attribute = true;
@@ -404,11 +405,6 @@ void catalog_update(JCR *jcr, BSOCK *bs)
       Dmsg2(400, "dird<filed: stream=%d %s\n", Stream, fname);
       Dmsg1(400, "dird<filed: attr=%s\n", attr);
 
-#ifdef xxx_old_code
-      if (!db_create_file_attributes_record(jcr, jcr->db, ar)) {
-         Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), db_strerror(jcr->db));
-      }
-#endif
    } else if (crypto_digest_stream_type(Stream) != CRYPTO_DIGEST_NONE) {
       fname = p;
       if (ar->FileIndex != FileIndex) {