};
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;
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"));
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;
/* 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)) {
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;
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);
*/
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 */
};
// 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 */
/* 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);
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:
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;