- if (!user_select_jobids(ua, &ji)) {
- return 0;
- }
-
- /*
- * Build the directory tree containing JobIds user selected
- */
- tree.root = new_tree(ji.TotalFiles);
- tree.root->fname = nofname;
- tree.ua = ua;
- query = get_pool_memory(PM_MESSAGE);
- last_JobId = 0;
- /*
- * For display purposes, the same JobId, with different volumes may
- * appear more than once, however, we only insert it once.
- */
- for (p=ji.JobIds; next_jobid_from_list(&p, &JobId) > 0; ) {
-
- if (JobId == last_JobId) {
- continue; /* eliminate duplicate JobIds */
- }
- last_JobId = JobId;
- bsendmsg(ua, _("Building directory tree for JobId %u ...\n"), JobId);
- /*
- * Find files for this JobId and insert them in the tree
- */
- Mmsg(&query, uar_sel_files, JobId);
- if (!db_sql_query(ua->db, query, insert_tree_handler, (void *)&tree)) {
- bsendmsg(ua, "%s", db_strerror(ua->db));
- }
- /*
- * Find the FileSets for this JobId and add to the name_list
- */
- Mmsg(&query, uar_mediatype, JobId);
- if (!db_sql_query(ua->db, query, unique_name_list_handler, (void *)&name_list)) {
- bsendmsg(ua, "%s", db_strerror(ua->db));
- }
-
- }
- bsendmsg(ua, "%d items inserted into the tree and marked for extraction.\n");
- free_pool_memory(query);
-
- /* Check MediaType and select storage that corresponds */
- get_storage_from_mediatype(ua, &name_list, &ji);
- free_name_list(&name_list);
-
- /* Let the user select which files to restore */
- user_select_files(&tree);
-
- /*
- * Walk down through the tree finding all files marked to be
- * extracted making a bootstrap file.
- */
- bsr = new_bsr();
- for (TREE_NODE *node=first_tree_node(tree.root); node; node=next_tree_node(node)) {
- Dmsg2(400, "FI=%d node=0x%x\n", node->FileIndex, node);
- if (node->extract) {
- Dmsg2(400, "type=%d FI=%d\n", node->type, node->FileIndex);
- add_findex(bsr, node->JobId, node->FileIndex);
- selected_files++;