}
start_prompt(ua, _("Defined Pools:\n"));
+ if (bstrcmp(argk, NT_("recyclepool"))) {
+ add_prompt(ua, _("*None*"));
+ }
for (i=0; i < num_pools; i++) {
opr.PoolId = ids[i];
if (!db_get_pool_record(ua->jcr, ua->db, &opr) ||
if (do_prompt(ua, _("Pool"), _("Select the Pool"), name, sizeof(name)) < 0) {
return false;
}
- memset(&opr, 0, sizeof(opr));
- bstrncpy(opr.Name, name, sizeof(opr.Name));
- if (!db_get_pool_record(ua->jcr, ua->db, &opr)) {
- ua->error_msg(_("Could not find Pool \"%s\": ERR=%s"), name, db_strerror(ua->db));
- return false;
+ memset(&opr, 0, sizeof(opr));
+ /* *None* is only returned when selecting a recyclepool, and in that case
+ * the calling code is only interested in opr.Name, so then we can leave
+ * pr as all zero.
+ */
+ if (!bstrcmp(name, _("*None*"))) {
+ bstrncpy(opr.Name, name, sizeof(opr.Name));
+
+ if (!db_get_pool_record(ua->jcr, ua->db, &opr)) {
+ ua->error_msg(_("Could not find Pool \"%s\": ERR=%s"), name, db_strerror(ua->db));
+ return false;
+ }
}
+
memcpy(pr, &opr, sizeof(opr));
return true;
}
{
POOL_DBR pr;
POOL_MEM query(PM_MESSAGE);
- char ed1[50], ed2[50];
-
- memset(&pr, 0, sizeof(pr));
- bstrncpy(pr.Name, val, sizeof(pr.Name));
- if (!get_pool_dbr(ua, &pr, NT_("recyclepool"))) {
- return;
- }
- /* pool = select_pool_resource(ua); */
- mr->RecyclePoolId = pr.PoolId; /* get the PoolId */
+ char ed1[50], ed2[50], *poolname;
+
+ if(val && *val) { /* update volume recyclepool="Scratch" */
+ /* If a pool name is given, look up the PoolId */
+ memset(&pr, 0, sizeof(pr));
+ bstrncpy(pr.Name, val, sizeof(pr.Name));
+ if (!get_pool_dbr(ua, &pr, NT_("recyclepool"))) {
+ return;
+ }
+ /* pool = select_pool_resource(ua); */
+ mr->RecyclePoolId = pr.PoolId; /* get the PoolId */
+ poolname = pr.Name;
+
+ } else { /* update volume recyclepool="" */
+ /* If no pool name is given, set the PoolId to 0 (the default) */
+ mr->RecyclePoolId = 0;
+ poolname = _("*None*");
+ }
db_lock(ua->db);
Mmsg(query, "UPDATE Media SET RecyclePoolId=%s WHERE MediaId=%s",
if (!db_sql_query(ua->db, query.c_str(), NULL, NULL)) {
ua->error_msg("%s", db_strerror(ua->db));
} else {
- ua->info_msg(_("New RecyclePool is: %s\n"), pr.Name);
+ ua->info_msg(_("New RecyclePool is: %s\n"), poolname);
}
db_unlock(ua->db);
}
if (db_get_pool_record(ua->jcr, ua->db, &pr)) {
ua->info_msg(_("Current RecyclePool is: %s\n"), pr.Name);
} else {
- ua->warning_msg(_("No current RecyclePool\n"));
- }
- if (!get_cmd(ua, _("Enter new RecyclePool name: "))) {
- return 0;
+ ua->info_msg(_("No current RecyclePool\n"));
}
- update_vol_recyclepool(ua, ua->cmd, &mr);
+ if (!select_pool_dbr(ua, &pr, NT_("recyclepool"))) {
+ return 0;
+ }
+ update_vol_recyclepool(ua, pr.Name, &mr);
return 1;
default: /* Done or error */