]> git.sur5r.net Git - bacula/bacula/commitdiff
Correct updating count of number of Volumes in a pool.
authorKern Sibbald <kern@sibbald.com>
Wed, 18 May 2005 15:09:44 +0000 (15:09 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 18 May 2005 15:09:44 +0000 (15:09 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2062 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kes-1.37
bacula/src/cats/sql_get.c
bacula/src/cats/sql_update.c
bacula/src/dird/newvol.c

index e8416a29077125b964b2a768fd9c61e1db6d561f..3a1d8f7887581a3467535a8352d1692e173f1942 100644 (file)
@@ -7,6 +7,7 @@ Changes to 1.37.19:
 18May05
 - Modify wait during use_device to happen only after all devices
   have been examined rather than in the reserve_device code.  
+- Correct updating count of number of Volumes in a pool.
 
 Changes to 1.37.18:
 16May05
index 856ae1cf48fac60d80c411154d083e955638d331..acd1d886cfe726e0f1485d374cfe84bcabd83ec7 100644 (file)
    Copyright (C) 2000-2005 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   modify it under the terms of the GNU General Public License
+   version 2 as ammended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public
-   License along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -587,16 +582,21 @@ bool db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pdbr)
             bstrncpy(pdbr->LabelFormat, row[16]!=NULL?row[16]:"", sizeof(pdbr->LabelFormat));
             ok = true;
          }
-      } else {
-         Mmsg(mdb->errmsg, _("Pool record not found in Catalog.\n"));
       }
       sql_free_result(mdb);
-   } else {
-      Mmsg(mdb->errmsg, _("Pool record not found in Catalog.\n"));
    }
    if (ok) {
-      Mmsg(mdb->cmd, "SELECT count(*) from Pool");
-      pdbr->NumVols = get_sql_record_max(jcr, mdb);
+      uint32_t NumVols;
+      Mmsg(mdb->cmd, "SELECT count(*) from Media WHERE PoolId=%s",
+         edit_int64(pdbr->PoolId, ed1));
+      NumVols = get_sql_record_max(jcr, mdb);
+      Dmsg2(400, "Actual NumVols=%d Pool NumVols=%d\n", NumVols, pdbr->NumVols);
+      if (NumVols != pdbr->NumVols) {
+         pdbr->NumVols = NumVols;
+         db_update_pool_record(jcr, mdb, pdbr);
+      }
+   } else {
+      Mmsg(mdb->errmsg, _("Pool record not found in Catalog.\n"));
    }
    db_unlock(mdb);
    return ok;
index 6e098bddaf67ad11e5d69ff5825afef2e4bdadca..8ff9cd4cfee2003a369776d0d1d8f4bf36d70591 100644 (file)
@@ -238,8 +238,10 @@ db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
    char ed1[50], ed2[50], ed3[50], ed4[50];
 
    db_lock(mdb);
-   Mmsg(mdb->cmd, "SELECT count(*) from Pool");
+   Mmsg(mdb->cmd, "SELECT count(*) from Media WHERE PoolId=%s",
+      edit_int64(pr->PoolId, ed4));
    pr->NumVols = get_sql_record_max(jcr, mdb);
+   Dmsg1(400, "NumVols=%d\n", pr->NumVols);
 
    Mmsg(mdb->cmd,
 "UPDATE Pool SET NumVols=%u,MaxVols=%u,UseOnce=%d,UseCatalog=%d,"
@@ -253,7 +255,7 @@ db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
       edit_uint64(pr->MaxVolBytes, ed3),
       pr->Recycle, pr->AutoPrune, pr->LabelType,
       pr->LabelFormat, 
-      edit_int64(pr->PoolId, ed4));
+      ed4);
 
    stat = UPDATE_DB(jcr, mdb, mdb->cmd);
    db_unlock(mdb);
index e82d2ebdf28626e671bc46dc60c91b2beb786d77..28dd85738f4b944bce9dd97ff5bbf155f36da79c 100644 (file)
  *   Version $Id$
  */
 /*
-   Copyright (C) 2001-2005 Kern Sibbald
+   Copyright (C) 2000-2005 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   modify it under the terms of the GNU General Public License
+   version 2 as ammended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public
-   License along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */