]> git.sur5r.net Git - bacula/bacula/commitdiff
When using "Restore from job" option with a job that was a restore
authorDirk H Bartley <dbartley@schupan.com>
Fri, 18 May 2007 15:46:29 +0000 (15:46 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Fri, 18 May 2007 15:46:29 +0000 (15:46 +0000)
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

bacula/src/qt-console/TODO
bacula/src/qt-console/joblist/joblist.cpp
bacula/src/qt-console/joblist/joblist.h
bacula/src/qt-console/restore/prerestore.cpp
bacula/src/qt-console/restore/restore.h

index f46b6838d172c667ec5053d5fbeac308adf9a7ec..9c8ab0b745c3c4462aa4a5cf86d0d1b14884eb39 100644 (file)
@@ -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.
index cf3fb97a94c82ccbea2751ebd6ea22da8fc374b4..13d4b55c6f42025f4a821f32829471e979bb95c0 100644 (file)
@@ -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);
+      }
    }
 }
 
index 6b56c8accb7fad4b502a218bd8a0f635526fbc5f..2f68096b85edf9a40fc2f722bd9ea46b90ae5220 100644 (file)
@@ -74,6 +74,7 @@ private:
    bool m_populated;
    bool m_checkCurrentWidget;
    int m_purgedIndex;
+   int m_typeIndex;
 };
 
 #endif /* _JOBLIST_H_ */
index d07ab66312832239a572ee9fbeaa6245f5fef079..9ff37cf9b04087264dcd139aaf2b687d4447eb69 100644 (file)
@@ -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;
    }
index 7fe23641b3858768006a733753c4d5d86919854c..af5619660d8df41e9d6b83328d71f750fe2eced8 100644 (file)
@@ -68,7 +68,7 @@ private slots:
    void jobIdEditFinished();
 
 private:
-   void jobdefsFromJob(QStringList &, QString);
+   int jobdefsFromJob(QStringList &, QString &);
    void buildPage();
    bool checkJobIdList();
    QString m_dtformat;