From 8540127e2a623a0d283100c5008926a115da9fb7 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Sun, 25 Feb 2007 12:01:03 +0000 Subject: [PATCH] ebl Add new Pool loop to set RecyclePoolId no need to use update pool=xxx git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4250 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/dird.c | 5 +++++ bacula/src/dird/protos.h | 1 + bacula/src/dird/ua_cmds.c | 32 +++++++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index c4b4433d8e..62c38dee31 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -763,6 +763,11 @@ static int check_resources() create_pool(NULL, db, pool, POOL_OP_UPDATE); /* update request */ } + /* Loop over all pools for updating RecyclePool */ + foreach_res(pool, R_POOL) { + update_pool_recyclepool(NULL, db, pool); + } + STORE *store; foreach_res(store, R_STORAGE) { STORAGE_DBR sr; diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index 440b27618f..07884fcbc8 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -182,6 +182,7 @@ int create_pool(JCR *jcr, B_DB *db, POOL *pool, e_pool_op op); void set_pool_dbr_defaults_in_media_dbr(MEDIA_DBR *mr, POOL_DBR *pr); bool set_pooldbr_recyclepoolid(JCR *jcr, B_DB *db, POOL_DBR *pr, POOL *pool); void set_pooldbr_from_poolres(POOL_DBR *pr, POOL *pool, e_pool_op op); +int update_pool_recyclepool(JCR *jcr, B_DB *db, POOL *pool); /* ua_input.c */ int get_cmd(UAContext *ua, const char *prompt); diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 45ef40ef57..917cf28a51 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -532,6 +532,37 @@ void set_pooldbr_from_poolres(POOL_DBR *pr, POOL *pool, e_pool_op op) } } +/* set/update Pool.RecyclePoolId in Catalog */ +int update_pool_recyclepool(JCR *jcr, B_DB *db, POOL *pool) +{ + POOL_DBR pr; + + if (!pool->RecyclePool) { + return 1; + } + + memset(&pr, 0, sizeof(POOL_DBR)); + bstrncpy(pr.Name, pool->name(), sizeof(pr.Name)); + + if (!db_get_pool_record(jcr, db, &pr)) { + return -1; /* not exists in database */ + } + + set_pooldbr_from_poolres(&pr, pool, POOL_OP_UPDATE); + + if (!set_pooldbr_recyclepoolid(jcr, db, &pr, pool)) { + return -1; /* error */ + } + + if (!db_update_pool_record(jcr, db, &pr)) { + return -1; /* error */ + } + return 1; +} + +/* set POOL_DBR.RecyclePoolId from Pool resource + * works with set_pooldbr_from_poolres + */ bool set_pooldbr_recyclepoolid(JCR *jcr, B_DB *db, POOL_DBR *pr, POOL *pool) { POOL_DBR rpool; @@ -584,7 +615,6 @@ int create_pool(JCR *jcr, B_DB *db, POOL *pool, e_pool_op op) } set_pooldbr_from_poolres(&pr, pool, op); - set_pooldbr_recyclepoolid(jcr, db, &pr, pool); if (!db_create_pool_record(jcr, db, &pr)) { return -1; /* error */ -- 2.39.5