]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/tools/bvfs_test.c
Backport of class based catalog backends into Branch-5.1.
[bacula/bacula] / bacula / src / tools / bvfs_test.c
index 75091d4d8621ec973b9b3a13b85a4b3850c01ebf..2cfbd13192f8d5bb50f7538f4ca4d29d93b59861 100644 (file)
@@ -6,7 +6,7 @@
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    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
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -36,6 +36,7 @@
 
 #include "bacula.h"
 #include "cats/cats.h"
+#include "cats/sql_glue.h"
 #include "cats/bvfs.h"
 #include "findlib/find.h"
  
@@ -80,15 +81,16 @@ static int result_handler(void *ctx, int fields, char **row)
    decode_stat((row[BVFS_LStat] && row[BVFS_LStat][0])?row[BVFS_LStat]:empty,
                &attr->statp, &attr->LinkFI);
 
-   if (fields == BVFS_DIR_RECORD || fields == BVFS_FILE_RECORD) {
+   if (bvfs_is_dir(row) || bvfs_is_file(row))
+   {
       /* display clean stuffs */
 
-      if (fields == BVFS_DIR_RECORD) {
+      if (bvfs_is_dir(row)) {
          pm_strcpy(attr->ofname, bvfs_basename_dir(row[BVFS_Name]));   
       } else {
          /* if we see the requested file, note his filenameid */
          if (bstrcmp(row[BVFS_Name], file)) {
-            fnid = str_to_int64(row[BVFS_Id]);
+            fnid = str_to_int64(row[BVFS_FilenameId]);
          }
          pm_strcpy(attr->ofname, row[BVFS_Name]);   
       }
@@ -96,7 +98,7 @@ static int result_handler(void *ctx, int fields, char **row)
 
    } else {
       Pmsg5(0, "JobId=%s FileId=%s\tMd5=%s\tVolName=%s\tVolInChanger=%s\n",
-            row[BVFS_JobId], row[BVFS_Id], row[BVFS_Md5], row[BVFS_VolName],
+            row[BVFS_JobId], row[BVFS_FileId], row[BVFS_Md5], row[BVFS_VolName],
             row[BVFS_VolInchanger]);
 
       pm_strcpy(attr->ofname, file);
@@ -209,11 +211,11 @@ int main (int argc, char *argv[])
    pm_strcpy(bjcr->client_name, "Dummy.Client.Name");
    bstrncpy(bjcr->Job, "bvfs_test", sizeof(bjcr->Job));
    
-   if ((db=db_init_database(NULL, db_name, db_user, db_password,
-                            db_host, 0, NULL, 0)) == NULL) {
+   if ((db = db_init_database(NULL, NULL, db_name, db_user, db_password,
+                              db_host, 0, NULL, false, false)) == NULL) {
       Emsg0(M_ERROR_TERM, 0, _("Could not init Bacula database\n"));
    }
-   Dmsg1(0, "db_type=%s\n", db_get_type());
+   Dmsg1(0, "db_type=%s\n", db_get_type(db));
 
    if (!db_open_database(NULL, db)) {
       Emsg0(M_ERROR_TERM, 0, db_strerror(db));
@@ -227,9 +229,9 @@ int main (int argc, char *argv[])
 
    if (clean) {
       Pmsg0(0, "Clean old table\n");
-      db_sql_query(db, "DELETE FROM brestore_pathhierarchy", NULL, NULL);
-      db_sql_query(db, "DELETE FROM brestore_knownjobid", NULL, NULL);
-      db_sql_query(db, "DELETE FROM brestore_pathvisibility", NULL, NULL);
+      db_sql_query(db, "DELETE FROM PathHierarchy", NULL, NULL);
+      db_sql_query(db, "UPDATE Job SET HasCache=0", NULL, NULL);
+      db_sql_query(db, "DELETE FROM PathVisibility", NULL, NULL);
       bvfs_update_cache(bjcr, db);
    }