From: Kern Sibbald Date: Fri, 5 Oct 2007 14:59:31 +0000 (+0000) Subject: kes Fix listing performance problems in bat. Pointed out by X-Git-Tag: Release-2.2.5~10 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=40dbd7dac7988cc09f1e25e310badaeb26d8a6b8;p=bacula%2Fbacula 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 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@5725 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/projects b/bacula/projects index 6b99f5fc6a..55820d6946 100644 --- a/bacula/projects +++ b/bacula/projects @@ -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 diff --git a/bacula/src/dird/query.sql b/bacula/src/dird/query.sql index c9f27f9893..b18f10fd65 100644 --- a/bacula/src/dird/query.sql +++ b/bacula/src/dird/query.sql @@ -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 diff --git a/bacula/src/qt-console/bat.h b/bacula/src/qt-console/bat.h index 608b15cc60..650f6fec19 100644 --- a/bacula/src/qt-console/bat.h +++ b/bacula/src/qt-console/bat.h @@ -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_ */ diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index 157ea5b253..59c5143e59 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -34,6 +34,15 @@ #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 diff --git a/bacula/src/qt-console/restore/restore.cpp b/bacula/src/qt-console/restore/restore.cpp index 26114225db..73661b4e06 100644 --- a/bacula/src/qt-console/restore/restore.cpp +++ b/bacula/src/qt-console/restore/restore.cpp @@ -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); diff --git a/bacula/src/qt-console/restore/restoretree.cpp b/bacula/src/qt-console/restore/restoretree.cpp index e1594a39b9..0bec98106e 100644 --- a/bacula/src/qt-console/restore/restoretree.cpp +++ b/bacula/src/qt-console/restore/restoretree.cpp @@ -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, ""); diff --git a/bacula/src/qt-console/restore/restoretree.h b/bacula/src/qt-console/restore/restoretree.h index be99c492e2..1ad1f176ea 100644 --- a/bacula/src/qt-console/restore/restoretree.h +++ b/bacula/src/qt-console/restore/restoretree.h @@ -102,7 +102,6 @@ private: bool m_dropdownChanged; QRegExp m_winRegExpDrive; QRegExp m_winRegExpPath; - QRegExp m_slashregex; bool m_slashTrap; QHash m_dirPaths; QString m_checkedJobs, m_prevJobCombo, m_prevClientCombo, m_prevFileSetCombo; diff --git a/bacula/src/tools/bsmtp.c b/bacula/src/tools/bsmtp.c index 83b0e552dc..c1a3e22110 100644 --- a/bacula/src/tools/bsmtp.c +++ b/bacula/src/tools/bsmtp.c @@ -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 */ diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index 025c71c751..81fc03299c 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -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