]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/restore.c
ebl Modify disk-changer to check if slot contains something before
[bacula/bacula] / bacula / src / filed / restore.c
index 1aa65ec22a126c8dd7d590627757d024d4b320f0..299b78f9e2a5b33902fbe92add40c289f14028d2 100644 (file)
@@ -120,7 +120,7 @@ bool flush_cipher(JCR *jcr, BFILE *bfd, uint64_t *addr, int flags,
 
 /*
  * Close a bfd check that we are at the expected file offset.
- * Makes some code in set_attributes().
+ * Makes use of some code from set_attributes().
  */
 static int bclose_chksize(JCR *jcr, BFILE *bfd, boffset_t osize)
 {
@@ -299,7 +299,11 @@ void do_restore(JCR *jcr)
                deallocate_fork_cipher(rctx);
             }
 
-            set_attributes(jcr, attr, &rctx.bfd);
+            if (jcr->plugin) {
+               plugin_set_attributes(jcr, attr, &rctx.bfd);
+            } else {
+               set_attributes(jcr, attr, &rctx.bfd);
+            }
             extract = false;
 
             /* Verify the cryptographic signature, if any */
@@ -316,6 +320,11 @@ void do_restore(JCR *jcr)
             bclose(&rctx.bfd);
          }
 
+         /* TODO: manage deleted files */
+         if (rctx.type == FT_DELETED) { /* deleted file */
+            continue;
+         }
+
          /*
           * Unpack attributes and do sanity check them
           */
@@ -345,11 +354,16 @@ void do_restore(JCR *jcr)
          build_attr_output_fnames(jcr, attr);
 
          /*
-          * Now determine if we are extracting or not.
+          * Try to actually create the file, which returns a status telling
+          *  us if we need to extract or not.
           */
          jcr->num_files_examined++;
          extract = false;
-         stat = create_file(jcr, attr, &rctx.bfd, jcr->replace);
+         if (jcr->plugin) {
+            stat = plugin_create_file(jcr, attr, &rctx.bfd, jcr->replace);
+         } else {
+            stat = create_file(jcr, attr, &rctx.bfd, jcr->replace);
+         }
          Dmsg2(30, "Outfile=%s create_file stat=%d\n", attr->ofname, stat);
          switch (stat) {
          case CF_ERROR:
@@ -376,7 +390,11 @@ void do_restore(JCR *jcr)
             }
             if (!extract) {
                /* set attributes now because file will not be extracted */
-               set_attributes(jcr, attr, &rctx.bfd);
+               if (jcr->plugin) {
+                  plugin_set_attributes(jcr, attr, &rctx.bfd);
+               } else {
+                  set_attributes(jcr, attr, &rctx.bfd);
+               }
             }
             break;
          }
@@ -632,6 +650,7 @@ void do_restore(JCR *jcr)
          break;
 
       case STREAM_PLUGIN_NAME:
+         Dmsg1(000, "restore stream_plugin_name=%s\n", sd->msg);
          plugin_name_stream(jcr, sd->msg);
          break;
 
@@ -646,7 +665,11 @@ void do_restore(JCR *jcr)
             deallocate_cipher(rctx);
             deallocate_fork_cipher(rctx);
 
-            set_attributes(jcr, attr, &rctx.bfd);
+            if (jcr->plugin) {
+               plugin_set_attributes(jcr, attr, &rctx.bfd);
+            } else {
+               set_attributes(jcr, attr, &rctx.bfd);
+            }
 
             /* Verify the cryptographic signature if any */
             rctx.type = attr->type;
@@ -675,7 +698,11 @@ void do_restore(JCR *jcr)
       deallocate_cipher(rctx);
       deallocate_fork_cipher(rctx);
 
-      set_attributes(jcr, attr, &rctx.bfd);
+      if (jcr->plugin) {
+         plugin_set_attributes(jcr, attr, &rctx.bfd);
+      } else {
+         set_attributes(jcr, attr, &rctx.bfd);
+      }
 
       /* Verify the cryptographic signature on the last file, if any */
       rctx.type = attr->type;
@@ -1087,7 +1114,6 @@ int32_t extract_data(JCR *jcr, BFILE *bfd, POOLMEM *buf, int32_t buflen,
        * packet length may be re-read by unser_crypto_packet_len() */
       cipher_ctx->packet_len = 0;
    }
-
    return wsize;
 }