]> git.sur5r.net Git - bacula/bacula/commitdiff
Ensure that Job duration is not negative
authorKern Sibbald <kern@sibbald.com>
Sat, 25 Dec 2010 12:56:58 +0000 (13:56 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:39:47 +0000 (14:39 +0200)
bacula/src/qt-console/job/job.cpp

index 20514cec5b48d607c827327708662b43f9f30b68..c9db572e6299fd4efde63e5911e9049f9629ce9a 100644 (file)
@@ -223,7 +223,7 @@ void Job::populateForm()
       "WHERE JobId=" + m_jobId; 
    QStringList results;
    if (m_console->sql_cmd(query, results)) {
-      QString resultline;
+      QString resultline, duration;
       QStringList fieldlist;
 
       foreach (resultline, results) { // should have only one result
@@ -240,14 +240,23 @@ void Job::populateForm()
          label_SchedTime->setText(fld.next());
          label_StartTime->setText(fld.next());
          label_EndTime->setText(fld.next());
-         label_Duration->setText(fld.next());
+         duration = fld.next();
+         /* 
+          * Note: if we have a negative duration, it is because the EndTime
+          *  is zero (i.e. the Job is still running).  We should use 
+          *  duration = StartTime - current_time
+          */
+         if (duration.left(1) == "-") {
+            duration = "0.0";
+         }
+         label_Duration->setText(duration);
 
          label_JobBytes->setText(convertBytesSI(fld.next().toULongLong()));
          label_JobFiles->setText(fld.next());
          err = fld.next();
          label_JobErrors->setText(err);
 
-         stat=fld.next();
+         stat = fld.next();
          if (stat == "T" && err.toInt() > 0) {
             stat = "W";
          }