From: Eric Bollengier Date: Wed, 5 Mar 2008 10:03:44 +0000 (+0000) Subject: ebl Apply Allan patch that allow update volume=xx recyclepool="" X-Git-Tag: Release-7.0.0~4909 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e5c29249b0b0471ee5c1224e5519903dd700a848;p=bacula%2Fbacula ebl Apply Allan patch that allow update volume=xx recyclepool="" git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6533 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/ua_select.c b/bacula/src/dird/ua_select.c index 5a684eb40a..598ec5a630 100644 --- a/bacula/src/dird/ua_select.c +++ b/bacula/src/dird/ua_select.c @@ -494,6 +494,9 @@ bool select_pool_dbr(UAContext *ua, POOL_DBR *pr, const char *argk) } 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) || @@ -506,13 +509,21 @@ bool select_pool_dbr(UAContext *ua, POOL_DBR *pr, const char *argk) 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; } diff --git a/bacula/src/dird/ua_update.c b/bacula/src/dird/ua_update.c index f7e38bd5e6..4f7823df91 100644 --- a/bacula/src/dird/ua_update.c +++ b/bacula/src/dird/ua_update.c @@ -333,15 +333,24 @@ void update_vol_recyclepool(UAContext *ua, char *val, MEDIA_DBR *mr) { 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", @@ -349,7 +358,7 @@ void update_vol_recyclepool(UAContext *ua, char *val, MEDIA_DBR *mr) 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); } @@ -763,12 +772,12 @@ static int update_volume(UAContext *ua) 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 */ diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 095d91d4f9..666b4e7ed0 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -1,6 +1,8 @@ Technical notes on version 2.3 General: +05Mar08 +ebl Apply Allan patch that permit to reset recyclepool. 04Mar08 kes Test patch -- possible fix or improvement for bug #1053 kes Refactor FD and SD status commands to permit new API code in