]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/backup.c
Do not try to strip RestoreObject during attribute encoding
[bacula/bacula] / bacula / src / filed / backup.c
index a17e8ceb3f3af319751d0f4b2fe4afc03e05e191..da9330feff0a1a46ed70596c0921874b637dbba7 100644 (file)
@@ -459,6 +459,9 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
       jcr->JobErrors++;
       return 1;
    }
+   case FT_DELETED:
+      Dmsg1(130, "FT_DELETED: %s\n", ff_pkt->fname);
+      break;
    default:
       Jmsg(jcr, M_NOTSAVED, 0,  _("     Unknown file type %d; not saved: %s\n"), 
            ff_pkt->type, ff_pkt->fname);
@@ -535,7 +538,7 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
       set_portable_backup(&ff_pkt->bfd); /* disable Win32 BackupRead() */
    }
 
-   if (ff_pkt->cmd_plugin && !ff_pkt->no_read) {
+   if (ff_pkt->cmd_plugin) {
       do_plugin_set = true;
 
    /* option and cmd plugin are not compatible together */
@@ -576,7 +579,10 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
    if (IS_FT_OBJECT(ff_pkt->type)) {
       goto good_rtn;
    }
-
+   /** Meta data only for deleted files */
+   if (ff_pkt->type == FT_DELETED) {
+      goto good_rtn;
+   }
    /** Set up the encryption context and send the session data to the SD */
    if (has_file_data && jcr->crypto.pki_encrypt) {
       if (!crypto_session_send(jcr, sd)) {
@@ -602,7 +608,7 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
       do_read = true;
    }
 
-   if (ff_pkt->cmd_plugin) {
+   if (ff_pkt->cmd_plugin && !ff_pkt->no_read) {
       do_read = true;
    }
 
@@ -1098,12 +1104,16 @@ static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest,
 #ifdef HAVE_LZO
       /** Do compression if turned on */
       if (ff_pkt->flags & FO_COMPRESS && ff_pkt->Compress_algo == COMPRESS_LZO1X && jcr->LZO_compress_workset) {
+         lzo_uint len;          /* TODO: See with the latest patch how to handle lzo_uint with 64bit */
+
          ser_declare;
          ser_begin(cbuf, sizeof(comp_stream_header));
 
          Dmsg3(400, "cbuf=0x%x rbuf=0x%x len=%u\n", cbuf, rbuf, sd->msglen);
 
-         lzores = lzo1x_1_compress((const unsigned char*)rbuf, sd->msglen, cbuf2, &compress_len, jcr->LZO_compress_workset);
+         lzores = lzo1x_1_compress((const unsigned char*)rbuf, sd->msglen, cbuf2, 
+                                   &len, jcr->LZO_compress_workset);
+         compress_len = len;
          if (lzores == LZO_E_OK && compress_len <= max_compress_len)
          {
             /* complete header */
@@ -1342,7 +1352,7 @@ bool encode_and_send_attributes(JCR *jcr, FF_PKT *ff_pkt, int &data_stream)
     * For a directory, link is the same as fname, but with trailing
     * slash. For a linked file, link is the link.
     */
-   if (ff_pkt->type != FT_DELETED) { /* already stripped */
+   if (!IS_FT_OBJECT(ff_pkt->type) && ff_pkt->type != FT_DELETED) { /* already stripped */
       strip_path(ff_pkt);
    }
    switch (ff_pkt->type) {
@@ -1404,7 +1414,8 @@ bool encode_and_send_attributes(JCR *jcr, FF_PKT *ff_pkt, int &data_stream)
                        attribsEx, 0, ff_pkt->delta_seq, 0);
       break;
    }
-   if (ff_pkt->type != FT_DELETED) {
+
+   if (!IS_FT_OBJECT(ff_pkt->type) && ff_pkt->type != FT_DELETED) {
       unstrip_path(ff_pkt);
    }
 
@@ -1430,8 +1441,10 @@ static bool do_strip(int count, char *in)
    while (*in && !IsPathSeparator(*in)) {    
       out++; in++;
    }
-   out++; in++;
-   numsep++;                     /* one separator seen */
+   if (*in) {                    /* Not at the end of the string */
+      out++; in++;
+      numsep++;                  /* one separator seen */
+   }
    for (stripped=0; stripped<count && *in; stripped++) {
       while (*in && !IsPathSeparator(*in)) {
          in++;                   /* skip chars */
@@ -1536,10 +1549,11 @@ static void close_vss_backup_session(JCR *jcr)
             Jmsg(jcr, msg_type, 0, _("VSS Writer (BackupComplete): %s\n"), g_pVSSClient->GetWriterInfo(i));
          }
       }
+      /* Generate Job global writer metadata */
       WCHAR *metadata = g_pVSSClient->GetMetadata();
       if (metadata) {
          FF_PKT *ff_pkt = jcr->ff;
-         ff_pkt->fname = (char *)"job";
+         ff_pkt->fname = (char *)"*all*"; /* for all plugins */
          ff_pkt->type = FT_RESTORE_FIRST;
          ff_pkt->LinkFI = 0;
          ff_pkt->object_name = (char *)"job_metadata.xml";