]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl Add new Pool loop to set RecyclePoolId
authorEric Bollengier <eric@eb.homelinux.org>
Sun, 25 Feb 2007 12:01:03 +0000 (12:01 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Sun, 25 Feb 2007 12:01:03 +0000 (12:01 +0000)
     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
bacula/src/dird/protos.h
bacula/src/dird/ua_cmds.c

index c4b4433d8e7006f16ac7751e0bcdf5a6e01dc482..62c38dee31da44e0d133512d29afdc037db29a6c 100644 (file)
@@ -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;
index 440b27618f6dc8a3ded7c38c95aa1e6d7c989ea1..07884fcbc87543ea15e65fa2affbd1033f14d782 100644 (file)
@@ -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);
index 45ef40ef57709439d1e4e9494f8da7d585c9bd85..917cf28a51360ccd1691996a93d99f4589e6bb2e 100644 (file)
@@ -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 */