]> git.sur5r.net Git - bacula/bacula/commitdiff
Cleanup restore_object packet
authorKern Sibbald <kern@sibbald.com>
Wed, 14 Apr 2010 08:40:16 +0000 (10:40 +0200)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 2 Aug 2010 14:50:32 +0000 (16:50 +0200)
bacula/src/cats/cats.h
bacula/src/cats/sql_create.c
bacula/src/dird/catreq.c
bacula/src/dird/fd_cmds.c
bacula/src/filed/fd_plugins.h
bacula/src/filed/job.c
bacula/src/plugins/fd/test-plugin-fd.c

index 423004ebd3780c8945a9bfeff955e2ddb99b62a8..1dc05e8d98e46b65b33a7ea552653a43882cce3c 100644 (file)
@@ -940,10 +940,7 @@ struct ATTR_DBR {
 };
 
 struct ROBJECT_DBR {
-   char *full_fname;
-   char *fname;
-   char *path;
-   char *plugin_name;
+   char *object_name;
    char *object;
    uint32_t object_len;
    uint32_t ObjectIndex;
index 10ff58084067d550c205ec636b64850dafd1f19e..44e016c46549b292cc0261c3b6df9fd8e7873377 100644 (file)
@@ -1267,25 +1267,21 @@ bool db_create_restore_object_record(JCR *jcr, B_DB *mdb, ROBJECT_DBR *ro)
    POOLMEM *esc_obj = get_pool_memory(PM_MESSAGE); 
    db_lock(mdb);
 
-   Dmsg1(dbglevel, "Fname=%s\n", ro->fname);
+   Dmsg1(dbglevel, "Oname=%s\n", ro->object_name);
    Dmsg0(dbglevel, "put_object_into_catalog\n");
 
-   split_path_and_file(jcr, mdb, ro->full_fname);
-
+   mdb->fnl = strlen(ro->object_name);
    mdb->esc_name = check_pool_memory_size(mdb->esc_name, mdb->fnl*2+1);
-   db_escape_string(jcr, mdb, mdb->esc_name, mdb->fname, mdb->fnl);
+   db_escape_string(jcr, mdb, mdb->esc_name, ro->object_name, mdb->fnl);
    
-   mdb->esc_path = check_pool_memory_size(mdb->esc_path, mdb->pnl*2+1);
-   db_escape_string(jcr, mdb, mdb->esc_path, mdb->path, mdb->pnl);
-
    esc_obj = check_pool_memory_size(esc_obj, ro->object_len*2+1);
    db_escape_string(jcr, mdb, esc_obj, ro->object, ro->object_len);
 
    Mmsg(mdb->cmd,
-        "INSERT INTO RestoreObject (Fname,Path,PluginName,RestoreObject,"
+        "INSERT INTO RestoreObject (Fname,RestoreObject,"
         "ObjectLength,ObjectIndex,ObjectType,FileIndex,JobId) VALUES"
-        "('%s','%s','%s','%s',%d,%d,%d,%d,%u)",
-        mdb->esc_name, mdb->esc_path, mdb->esc_path, esc_obj, ro->object_len,
+        "('%s','%s',%d,%d,%d,%d,%u)",
+        mdb->esc_name, esc_obj, ro->object_len,
         ro->ObjectIndex, FT_RESTORE_FIRST, ro->FileIndex, ro->JobId);
 
    ro->RestoreObjectId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("RestoreObject"));
index 1f765da18b324d91a4c120f40bfa594e82c33bab..5627db594271aa2a704d11623a52463ec008967b 100644 (file)
@@ -456,7 +456,7 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen)
          POOLMEM *attrEx = get_pool_memory(PM_MESSAGE);
          char *p;
          memset(&ro, 0, sizeof(ro));
-         ro.full_fname = fname;
+         ro.object_name = fname;
          ro.Stream = Stream;
          ro.FileType = ar->FileType;
          ro.FileIndex = FileIndex;
@@ -474,8 +474,8 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen)
          /* Add a EOS for those who attempt to print the object */
          p = attrEx + ro.object_len;
          *p = 0;
-         Dmsg7(000, "fname=%s stream=%d FT=%d FI=%d JobId=%d, obj_len=%d\nobj=\"%s\"\n",
-            ro.full_fname, ro.Stream, ro.FileType, ro.FileIndex, ro.JobId,
+         Dmsg7(000, "oname=%s stream=%d FT=%d FI=%d JobId=%d, obj_len=%d\nobj=\"%s\"\n",
+            ro.object_name, ro.Stream, ro.FileType, ro.FileIndex, ro.JobId,
             ro.object_len, attrEx);
          /* Send it */
          if (!db_create_restore_object_record(jcr, jcr->db, &ro)) {
index a500840644561b4c7de0440a4e9053472a488654..94b58dd2200b6abd1ab97b5d49b3617cd5f75dbf 100644 (file)
@@ -679,17 +679,16 @@ static int restore_object_handler(void *ctx, int num_fields, char **row)
       return 1;
    }
    fd->fsend("restoreobject JobId=%s ObjLen=%s ObjInx=%s ObjType=%s FI=%s\n",
-      row[0], row[3], row[6], row[7], row[8]);
+      row[0], row[1], row[2], row[3], row[4]);
 
-   fd->fsend("%s", row[1]);              /* send Fname */
-// Dmsg1(000, "Send obj: %s\n", fd->msg);
-
-   fd->fsend("%s", row[2]);              /* send Path */
+   msg_save = fd->msg;
+   fd->msg = row[5] ? row[5] : (char *)"";
+   fd->msglen = strlen(fd->msg);
+   fd->send();                            /* send Object name */
 // Dmsg1(000, "Send obj: %s\n", fd->msg);
 
-   msg_save = fd->msg;
-   fd->msg = row[4];                     /* object */
-   fd->msglen = str_to_uint64(row[3]);   /* object length */
+   fd->msg = row[6] ? row[6] : (char *)""; /* object */
+   fd->msglen = str_to_uint64(row[1]);   /* object length */
    fd->send();                           /* send object */
 // Dmsg1(000, "Send obj: %s\n", fd->msg);
    fd->msg = msg_save;
@@ -706,9 +705,9 @@ bool send_restore_objects(JCR *jcr)
    if (!jcr->JobIds || !jcr->JobIds[0]) {
       return true;
    }
-   Mmsg(query, "SELECT JobId,Fname,Path,ObjectLength,RestoreObject,"
-        "PluginName,ObjectIndex,ObjectType,FileIndex "
-        "FROM RestoreObject WHERE JobId IN (%s)", jcr->JobIds);
+   Mmsg(query, "SELECT JobId,ObjectLength,ObjectIndex,ObjectType,"
+        "FileIndex,Fname,RestoreObject FROM RestoreObject "
+        "WHERE JobId IN (%s) ORDER BY ObjectIndex ASC", jcr->JobIds);
    
    /* restore_object_handler is called for each file found */
    db_sql_query(jcr->db, query.c_str(), restore_object_handler, (void *)jcr);
index 7c37eaffcfb11c23b9a4c93956f2487926d02114..963451b4b497356188d83386901e1af7b44ea76a 100644 (file)
  */
 struct restore_object_pkt {
    int32_t pkt_size;                  /* size of this packet */
-   char *fname;                       /* Full path and filename */
-   int32_t object_type;               /* FT_xx for this file */             
+   char *object_name;                 /* Object name */
    char *object;                      /* restore object data to save */
+   int32_t object_type;               /* FT_xx for this file */             
    int32_t object_len;                /* restore object length */
    int32_t object_index;              /* restore object index */
+   int32_t stream;                    /* attribute stream id */
    uint32_t JobId;                    /* JobId object came from */
    int32_t pkt_end;                   /* end packet sentinel */
 };
index 66bf6c9735a8e8a7c946604e09c0d3dacbc4d3cf..b11466128a62cb906df6df8793faaedc46730244 100644 (file)
@@ -647,17 +647,13 @@ static int restore_object_cmd(JCR *jcr)
 
 // Dmsg5(000, "Recv object: JobId=%u objlen=%d objinx=%d objtype=%d FI=%d\n",
 //       JobId, object_len, object_index, object_type, FileIndex);
-   /* Read Fname */
+   /* Read Object name */
    if (dir->recv() < 0) {
       goto bail_out;
    }
-// Dmsg2(000, "Recv Fname object: len=%d Fname=%s\n", dir->msglen, dir->msg);
-   rop.fname = bstrdup(dir->msg);
+// Dmsg2(000, "Recv Fname object: len=%d Oname=%s\n", dir->msglen, dir->msg);
+   rop.object_name = bstrdup(dir->msg);
 
-   /* Read Path */
-   if (dir->recv() < 0) {
-      goto bail_out;
-   }
 // Dmsg2(000, "Recv Path object: len=%d Path=%s\n", dir->msglen, dir->msg);
 
    /* Read Object */
@@ -670,8 +666,8 @@ static int restore_object_cmd(JCR *jcr)
    /* pass to plugin */
    generate_plugin_event(jcr, bEventRestoreObject, (void *)&rop);
 
-   if (rop.fname) {
-      free(rop.fname);
+   if (rop.object_name) {
+      free(rop.object_name);
    }
    if (!rop.object) {
       dir->msg = get_pool_memory(PM_MESSAGE);
index 8165499f1ea063ef7483d25d5105844a7b8a1250..8a239e8b95669b88393d4e1b677232f598742330 100644 (file)
@@ -238,8 +238,8 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
          break;
       }
       rop = (restore_object_pkt *)value;
-      bfuncs->DebugMessage(ctx, fi, li, dbglvl, "test-plugin-fd: len=%d JobId=%d fname=%s\n",
-         rop->object_len, rop->JobId, rop->fname);
+      bfuncs->DebugMessage(ctx, fi, li, dbglvl, "test-plugin-fd: len=%d JobId=%d oname=%s\n",
+         rop->object_len, rop->JobId, rop->object_name);
       break;
    /* Plugin command e.g. plugin = <plugin-name>:<name-space>:read command:write command */
    case bEventRestoreCommand:
@@ -290,7 +290,7 @@ static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp)
       return bRC_Error;
    }
    time_t now = time(NULL);
-   sp->fname = p_ctx->fname;
+   sp->fname = (char *)"james.xml";
    sp->object = (char *)"This is test data for the restore object.";
    sp->object_len = strlen(sp->object);
    sp->index = 2;