]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Fix listing performance problems in bat. Pointed out by
authorKern Sibbald <kern@sibbald.com>
Fri, 5 Oct 2007 14:59:31 +0000 (14:59 +0000)
committerKern Sibbald <kern@sibbald.com>
Fri, 5 Oct 2007 14:59:31 +0000 (14:59 +0000)
     Chris Howells.
ebl  Fix replace on restore. This fixes bug #969
kes  Fix bat code that tests for Win32. This should fix bug #968
kes  Query 5 list wrong Vol after migration. This fixes bug #960

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@5725 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/projects
bacula/src/dird/query.sql
bacula/src/qt-console/bat.h
bacula/src/qt-console/pages.cpp
bacula/src/qt-console/restore/restore.cpp
bacula/src/qt-console/restore/restoretree.cpp
bacula/src/qt-console/restore/restoretree.h
bacula/src/tools/bsmtp.c
bacula/technotes-2.1

index 6b99f5fc6a5f38f63658549139c3214f03e3a0ea..55820d694657e2c0de750e06e059a36e76cdd197 100644 (file)
@@ -38,7 +38,7 @@ Item 25:  Archival (removal) of User Files to Tape
 Item  1:  Accurate restoration of renamed/deleted files
   Date:   28 November 2005
   Origin: Martin Simmons (martin at lispworks dot com)
-  Status: Robert Nelson will implement this
+  Status: 
 
   What:   When restoring a fileset for a specified date (including "most
           recent"), Bacula should give you exactly the files and directories
index c9f27f9893d60df83fd114671d916b1596368c07..b18f10fd65df9c66b545ae9f74de9bdf56e50c0d 100644 (file)
@@ -56,8 +56,8 @@ SELECT DISTINCT Job.JobId as JobId,Client.Name as Client,
    JobFiles,JobBytes,VolumeName
  FROM Client,Job,JobMedia,Media,FileSet
  WHERE Client.Name='%1'
- AND Client.ClientId=Job.ClientId
- AND JobStatus='T' AND Job.FileSetId=FileSet.FileSetId
+ AND Client.ClientId=Job.ClientId AND Job.Type='B'
+ AND Job.JobStatus='T' AND Job.FileSetId=FileSet.FileSetId
  AND JobMedia.JobId=Job.JobId AND JobMedia.MediaId=Media.MediaId
  ORDER BY Job.StartTime;
 # 6
index 608b15cc603e465d33404b8491a3dd77aec4ebcb..650f6fec19b4286e2c2a8eca781c5e0837b6b96c 100644 (file)
@@ -48,5 +48,6 @@ extern MainWin *mainWin;
 extern QApplication *app;
 
 int bvsnprintf(char *str, int32_t size, const char *format, va_list ap);
+bool isWin32Path(QString &fullPath);
 
 #endif /* _BAT_H_ */
index 157ea5b253a27f740c531e512eb7c6d06bf2be88..59c5143e59ce7e3122734a99e77aa2c74ba9d85d 100644 (file)
 #include "pages.h"
 #include "bat.h"
 
+/* A global function */
+bool isWin32Path(QString &fullPath) 
+{
+   char *buf = fullPath.left(2).toUtf8().data();
+
+   return buf[1] == ':' && B_ISALPHA(buf[0]);
+}
+
+
 /*
  * dockPage
  * This function is intended to be called from within the Pages class to pull
index 26114225dbe0a8f5e360329d1ef3902d046836e5..73661b4e06a6856e0f8f56ae35e2ab689cacf462 100644 (file)
@@ -181,7 +181,6 @@ void restorePage::addDirectory(QString &newdirr)
 {
    QString newdir = newdirr;
    QString fullpath = m_cwd + newdirr;
-   QRegExp regex("^/[a-z]:/$");
    bool ok = true;
    bool windrive = false;
 
@@ -193,7 +192,7 @@ void restorePage::addDirectory(QString &newdirr)
    }
 
    /* add unix '/' directory first */
-   if (m_dirPaths.empty() && (regex.indexIn(fullpath,0) == -1)) {
+   if (m_dirPaths.empty() && !isWin32Path(fullpath)) {
       QTreeWidgetItem *item = new QTreeWidgetItem(directoryWidget);
       item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
       
@@ -206,12 +205,11 @@ void restorePage::addDirectory(QString &newdirr)
       m_dirTreeItems.insert(item, text);
    }
 
-   if (regex.indexIn(fullpath,0) == 0) {
+   if (isWin32Path(fullpath)) {
       /* this is a windows drive */
       if (mainWin->m_miscDebug) {
          Pmsg0(000, "Need to do windows \"letter\":/\n");
       }
-      fullpath.replace(0,1,"");
       windrive = true;
    }
  
@@ -316,10 +314,6 @@ void restorePage::fileDoubleClicked(QTreeWidgetItem *item, int column)
     */
    if (item->text(1).endsWith("/")) {
       QString fullpath = m_cwd + item->text(1);
-      /* check for fullpath = "/c:/" */
-      QRegExp regex("^/[a-z]:/");
-      if (regex.indexIn(fullpath,0) == 0)  /* remove leading '/' */
-         fullpath.replace(0,1,"");
       QTreeWidgetItem *item = m_dirPaths.value(fullpath);
       if (item) {
          directoryWidget->setCurrentItem(item);
index e1594a39b9bec92a936fff99a66bf28733108e50..0bec98106ee1cc68e76988d0ba08e190266313b4 100644 (file)
@@ -51,9 +51,6 @@ restoreTree::restoreTree()
    m_populated = false;
 
    dockPage();
-   m_winRegExpDrive.setPattern("^[a-zA-Z]:/$");
-   m_winRegExpPath.setPattern("^[a-zA-Z]:/");
-   m_slashregex.setPattern("/");
    m_debugCnt = 0;
    m_debugTrap = true;
 
@@ -259,8 +256,10 @@ void restoreTree::populateDirectoryTree()
             Pmsg1(000, "Done with query %i results\n", results.count());
          QStringList fieldlist;
          foreach(QString resultline, results) {
-            m_debugCnt += 1;
-            prBar2->setValue(m_debugCnt);
+            /* Update progress bar periodically */
+            if ((++m_debugCnt && 0x3FF) == 0) {
+               prBar2->setValue(m_debugCnt);
+            }
             fieldlist = resultline.split("\t");
             int fieldcnt = 0;
             QString field;
@@ -324,15 +323,14 @@ void restoreTree::setJobsCheckedList()
  */
 void restoreTree::parseDirectory(QString &dir_in)
 {
-   /* m_debugTrap is to only print debugs for a few occurances of calling parseDirectory
+   /* m_debugTrap is to only print debugs for a few occurennces of calling parseDirectory
     * instead of printing out what could potentially a whole bunch */
    if (m_debugCnt > 2)
       m_debugTrap = false;
-   /* Clean up the directory string remove some funny char after last '/' */
-   QRegExp rgx("[^/]$");
-   int lastslash = rgx.indexIn(dir_in);
-   if (lastslash != -1)
-      dir_in.replace(lastslash, dir_in.length()-lastslash, "");
+   /* Truncate everything after the last / */
+   if (dir_in.right(1) != "/") {
+      dir_in.truncate(dir_in.lastIndexOf("/") + 1);
+   }
    if ((mainWin->m_miscDebug) && (m_debugTrap))
       Pmsg1(000, "parsing %s\n", dir_in.toUtf8().data());
 
@@ -344,7 +342,7 @@ void restoreTree::parseDirectory(QString &dir_in)
    /* start from the end, turn /etc/somedir/subdir/ into /etc/somedir and subdir/ 
     * if not added into tree, then try /etc/ and somedir/ if not added, then try
     * / and etc/ .  That should succeed, then add the ones that failed in reverse */
-   while (((index = m_slashregex.lastIndexIn(dir_in, -2)) != -1) && (!done)) {
+   while (((index = dir_in.lastIndexOf("/", -2)) != -1) && (!done)) {
       direct = path = dir_in;
       path.replace(index+1, dir_in.length()-index-1,"");
       direct.replace(0, index+1, "");
@@ -373,6 +371,7 @@ void restoreTree::parseDirectory(QString &dir_in)
    }
 }
 
+
 /*
  * Function called from fill directory when a directory is found to see if this
  * directory exists in the directory pane and then add it to the directory pane
@@ -392,7 +391,7 @@ bool restoreTree::addDirectory(QString &m_cwd, QString &newdirr)
 
    if (!m_slashTrap) {
       /* add unix '/' directory first */
-      if (m_dirPaths.empty() && (m_winRegExpPath.indexIn(fullPath, 0) == -1)) {
+      if (m_dirPaths.empty() && isWin32Path(fullPath)) {
          m_slashTrap = true;
          QTreeWidgetItem *item = new QTreeWidgetItem(directoryTree);
          QString text("/");
@@ -406,7 +405,7 @@ bool restoreTree::addDirectory(QString &m_cwd, QString &newdirr)
          m_dirPaths.insert(text, item);
       }
       /* no need to check for windows drive if unix */
-      if (m_winRegExpDrive.indexIn(m_cwd, 0) == 0) {
+      if (isWin32Path(m_cwd)) {
          if (!m_dirPaths.contains(m_cwd)) {
             /* this is a windows drive add the base widget */
             QTreeWidgetItem *item = new QTreeWidgetItem(directoryTree);
@@ -1280,7 +1279,7 @@ void restoreTree::fullPathtoSubPaths(QStringList &subPaths, QString &fullPath_in
    bool done = false;
    QString fullPath = fullPath_in;
    QString direct, path;
-   while (((index = m_slashregex.lastIndexIn(fullPath, -2)) != -1) && (!done)) {
+   while (((index = fullPath.lastIndexOf("/", -2)) != -1) && (!done)) {
       direct = path = fullPath;
       path.replace(index+1, fullPath.length()-index-1, "");
       direct.replace(0, index+1, "");
@@ -1730,7 +1729,7 @@ int restoreTree::mostRecentVersionfromFullPath(QString &fullPath)
 {
    int qversion = 0;
    QString directory, fileName;
-   int index = m_slashregex.lastIndexIn(fullPath, -2);
+   int index = fullPath.lastIndexOf("/", -2);
    if (index != -1) {
       directory = fileName = fullPath;
       directory.replace(index+1, fullPath.length()-index-1, "");
@@ -1783,7 +1782,7 @@ int restoreTree::queryFileIndex(QString &fullPath, int jobId)
 {
    int qfileIndex = 0;
    QString directory, fileName;
-   int index = m_slashregex.lastIndexIn(fullPath, -2);
+   int index = fullPath.lastIndexOf("/", -2);
    if (index != -1) {
       directory = fileName = fullPath;
       directory.replace(index+1, fullPath.length()-index-1, "");
index be99c492e2dce2f7b0300a41d53b308f6296ca1a..1ad1f176ea00c2e9017b329c9375e516085a2afb 100644 (file)
@@ -102,7 +102,6 @@ private:
    bool m_dropdownChanged;
    QRegExp m_winRegExpDrive;
    QRegExp m_winRegExpPath;
-   QRegExp m_slashregex;
    bool m_slashTrap;
    QHash<QString, QTreeWidgetItem *> m_dirPaths;
    QString m_checkedJobs, m_prevJobCombo, m_prevClientCombo, m_prevFileSetCombo;
index 83b0e552dc9c55bc81b874420342ddc24f9ccef4..c1a3e22110955f39ae5b3f831dd614181805e715 100644 (file)
@@ -107,7 +107,7 @@ static char *cleanup_addr(char *addr, char *buf, int buf_len)
 {
    char *p, *q;
 
-   if ((p = strchr(from_addr, '<')) == NULL) {
+   if ((p = strchr(addr, '<')) == NULL) {
       snprintf(buf, buf_len, "<%s>", addr);
    } else {
       /* Copy <addr> */
index 025c71c751ce0a6d391a95aa1c62e4b741775601..81fc03299c3b22b5a757210f77bd1b38430edaa4 100644 (file)
@@ -1,6 +1,12 @@
               Technical notes on version 2.2
 
 General:
+05Oct07
+kes  Fix listing performance problems in bat. Pointed out by 
+     Chris Howells.
+ebl  Fix replace on restore. This fixes bug #969
+kes  Fix bat code that tests for Win32. This should fix bug #968
+kes  Query 5 list wrong Vol after migration. This fixes bug #960
 04Oct07 
 kes  Correct lib/Makefile.in to include enh_fnmatch.o that was removed
      in back porting from 2.3.x
@@ -69,6 +75,7 @@ kes  Apply 2.2.4-poll-mount fix, that resolves bug #908 where a tape
      is not properly mounted (recognized) during a poll.
 kes  Apply 2.2.4-verify patch that resolves bug #958.  A Verify catalog 
      Job that has differences reports Verify OK.
+ebl  Fixes #955 bug seg fault in Dir introduced  with regexwhere relocation.
 
 Release Version 2.2.4
 14Sep07