From: Dirk H Bartley Date: Fri, 18 May 2007 15:46:29 +0000 (+0000) Subject: When using "Restore from job" option with a job that was a restore X-Git-Tag: Release-7.0.0~6314 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b489415a911bda499c3547ca91c29cac30511dc0;p=bacula%2Fbacula When using "Restore from job" option with a job that was a restore job, a segfault would occur. This prevents that and does not offer that option if the job is not a backup job. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4828 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/TODO b/bacula/src/qt-console/TODO index f46b6838d1..9c8ab0b745 100644 --- a/bacula/src/qt-console/TODO +++ b/bacula/src/qt-console/TODO @@ -1,5 +1,7 @@ dhb ==================================================== +Prevent the ablility of a user to close the original joblist page. + Further testing of restore with .mod Test left pane of restore with 2 windows drives in one backup job. @@ -80,6 +82,9 @@ global one defined in the mainWin class (if I remember right). ============================================================ DONE: ============================================================ +Can produce a segfault by attempting to restore from a restore job. In +pre-restore, prevent a job in the list from being a restore job. + Need to figure out the functionality and inteligence that the last restore window should have and give it to it. Right now it shows drop downs with no options. diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index cf3fb97a94..13d4b55c6f 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -187,6 +187,7 @@ void JobList::populateTable() << "Job Id" << "Job Name" << "Client" << "Job Starttime" << "Job Type" << "Job Level" << "Job Files" << "Job Bytes" << "Job Status" << "Purged" ); m_purgedIndex = headerlist.indexOf("Purged"); + m_typeIndex = headerlist.indexOf("Job Type"); statusIndex = headerlist.indexOf("Job Status"); /* Initialize the QTableWidget */ @@ -318,6 +319,14 @@ void JobList::tableItemChanged(QTableWidgetItem *currentItem, QTableWidgetItem * if (purged == "0") { mp_tableWidget->addAction(actionPurgeFiles); } + jobitem = mp_tableWidget->item(row, m_typeIndex); + QString status = jobitem->text(); + mp_tableWidget->removeAction(actionRestoreFromJob); + mp_tableWidget->removeAction(actionRestoreFromTime); + if (status == "B") { + mp_tableWidget->addAction(actionRestoreFromJob); + mp_tableWidget->addAction(actionRestoreFromTime); + } } } diff --git a/bacula/src/qt-console/joblist/joblist.h b/bacula/src/qt-console/joblist/joblist.h index 6b56c8accb..2f68096b85 100644 --- a/bacula/src/qt-console/joblist/joblist.h +++ b/bacula/src/qt-console/joblist/joblist.h @@ -74,6 +74,7 @@ private: bool m_populated; bool m_checkCurrentWidget; int m_purgedIndex; + int m_typeIndex; }; #endif /* _JOBLIST_H_ */ diff --git a/bacula/src/qt-console/restore/prerestore.cpp b/bacula/src/qt-console/restore/prerestore.cpp index d07ab66312..9ff37cf9b0 100644 --- a/bacula/src/qt-console/restore/prerestore.cpp +++ b/bacula/src/qt-console/restore/prerestore.cpp @@ -92,10 +92,11 @@ void prerestorePage::buildPage() jobIdEdit->setText(m_dataIn); jobRadioClicked(false); QStringList fieldlist; - jobdefsFromJob(fieldlist,m_dataIn); - filesetCombo->setCurrentIndex(filesetCombo->findText(fieldlist[2], Qt::MatchExactly)); - clientCombo->setCurrentIndex(clientCombo->findText(fieldlist[1], Qt::MatchExactly)); - jobCombo->setCurrentIndex(jobCombo->findText(fieldlist[0], Qt::MatchExactly)); + if (jobdefsFromJob(fieldlist, m_dataIn) == 1) { + filesetCombo->setCurrentIndex(filesetCombo->findText(fieldlist[2], Qt::MatchExactly)); + clientCombo->setCurrentIndex(clientCombo->findText(fieldlist[1], Qt::MatchExactly)); + jobCombo->setCurrentIndex(jobCombo->findText(fieldlist[0], Qt::MatchExactly)); + } } else if (m_dataInType == R_JOBDATETIME) { selectJobRadio->setChecked(true); selectJobIdsRadio->setChecked(false); @@ -104,11 +105,12 @@ void prerestorePage::buildPage() recentCheckBox->setCheckState(Qt::Unchecked); jobRadioClicked(true); QStringList fieldlist; - jobdefsFromJob(fieldlist,m_dataIn); - filesetCombo->setCurrentIndex(filesetCombo->findText(fieldlist[2], Qt::MatchExactly)); - clientCombo->setCurrentIndex(clientCombo->findText(fieldlist[1], Qt::MatchExactly)); - jobCombo->setCurrentIndex(jobCombo->findText(fieldlist[0], Qt::MatchExactly)); - beforeDateTime->setDateTime(QDateTime::fromString(fieldlist[3], m_dtformat)); + if (jobdefsFromJob(fieldlist, m_dataIn) == 1) { + filesetCombo->setCurrentIndex(filesetCombo->findText(fieldlist[2], Qt::MatchExactly)); + clientCombo->setCurrentIndex(clientCombo->findText(fieldlist[1], Qt::MatchExactly)); + jobCombo->setCurrentIndex(jobCombo->findText(fieldlist[0], Qt::MatchExactly)); + beforeDateTime->setDateTime(QDateTime::fromString(fieldlist[3], m_dtformat)); + } } job_name_change(0); connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int))); @@ -165,7 +167,7 @@ void prerestorePage::okButtonPushed() } /* ***FIXME*** */ - printf("preRestore command \'%s\'\n", cmd.toUtf8().data()); + //printf("preRestore command \'%s\'\n", cmd.toUtf8().data()); consoleCommand(cmd); /* Note, do not turn notifier back on here ... */ if (selectFilesRadio->isChecked()) { @@ -227,16 +229,17 @@ void prerestorePage::recentChanged(int state) * For when jobs list is to be used, return a list which is the needed items from * the job record */ -void prerestorePage::jobdefsFromJob(QStringList &fieldlist, QString jobId) +int prerestorePage::jobdefsFromJob(QStringList &fieldlist, QString &jobId) { QString job, client, fileset; QString query(""); query = "SELECT DISTINCT Job.Name AS JobName, Client.Name AS Client," - " FileSet.FileSet AS FileSet, Job.EndTime AS JobEnd" + " FileSet.FileSet AS FileSet, Job.EndTime AS JobEnd," + " Job.Type AS JobType" " From Job, Client, FileSet" " WHERE Job.FileSetId=FileSet.FileSetId AND Job.ClientId=Client.ClientId" " AND JobId=\'" + jobId + "\'"; - //printf("query = %s\n", query.toUtf8().data()); + printf("query = %s\n", query.toUtf8().data()); QStringList results; if (m_console->sql_cmd(query, results)) { QString field; @@ -246,6 +249,7 @@ void prerestorePage::jobdefsFromJob(QStringList &fieldlist, QString jobId) fieldlist = resultline.split("\t"); } /* foreach resultline */ } /* if results from query */ + return results.count(); } /* @@ -276,9 +280,7 @@ bool prerestorePage::checkJobIdList() /* are the intergers representing a list of jobs all with the same job * and client */ QStringList fields; - jobdefsFromJob(fields, job); - int count = fields.count(); - if (count > 0) { + if (jobdefsFromJob(fields, job) == 1) { if (jobName == "") jobName = fields[0]; else if (jobName != fields[0]) @@ -302,7 +304,7 @@ bool prerestorePage::checkJobIdList() } if (!allisjob){ QMessageBox::warning(this, tr("Bat"), - tr("At least one of the jobs is not a valid job.\n" + tr("At least one of the jobs is not a valid job of type \"Backup\".\n" "Press OK to continue?"), QMessageBox::Ok ); return false; } diff --git a/bacula/src/qt-console/restore/restore.h b/bacula/src/qt-console/restore/restore.h index 7fe23641b3..af5619660d 100644 --- a/bacula/src/qt-console/restore/restore.h +++ b/bacula/src/qt-console/restore/restore.h @@ -68,7 +68,7 @@ private slots: void jobIdEditFinished(); private: - void jobdefsFromJob(QStringList &, QString); + int jobdefsFromJob(QStringList &, QString &); void buildPage(); bool checkJobIdList(); QString m_dtformat;