]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix #1558 about bscan that doesn't update PurgedFiles on Job records
authorEric Bollengier <eric@eb.homelinux.org>
Fri, 23 Apr 2010 15:53:27 +0000 (17:53 +0200)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 2 Aug 2010 14:53:44 +0000 (16:53 +0200)
bacula/src/cats/sql_get.c
bacula/src/cats/sql_update.c
bacula/src/stored/bscan.c

index 540921ef08a7bb134e156d51bdd2864facfac5f4..e44dc47d4e220751151109096243f236c040872a 100644 (file)
@@ -290,13 +290,13 @@ bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
       Mmsg(mdb->cmd, "SELECT VolSessionId,VolSessionTime,"
 "PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus,"
 "Type,Level,ClientId,Name,PriorJobId,RealEndTime,JobId,FileSetId,"
-"SchedTime,RealEndTime,ReadBytes,HasBase "
+"SchedTime,RealEndTime,ReadBytes,HasBase,PurgedFiles "
 "FROM Job WHERE Job='%s'", jr->Job);
     } else {
       Mmsg(mdb->cmd, "SELECT VolSessionId,VolSessionTime,"
 "PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus,"
 "Type,Level,ClientId,Name,PriorJobId,RealEndTime,JobId,FileSetId,"
-"SchedTime,RealEndTime,ReadBytes,HasBase "
+"SchedTime,RealEndTime,ReadBytes,HasBase,PurgedFiles "
 "FROM Job WHERE JobId=%s", 
           edit_int64(jr->JobId, ed1));
     }
@@ -340,6 +340,7 @@ bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    jr->EndTime = str_to_utime(jr->cEndTime);
    jr->RealEndTime = str_to_utime(jr->cRealEndTime);
    jr->HasBase = str_to_int64(row[21]);
+   jr->PurgedFiles = str_to_int64(row[22]);
    sql_free_result(mdb);
 
    db_unlock(mdb);
index 7dba22031e76fb8811f965e045f6acb8df91b818..fbfee8db16446f4cafff9a6244ab8b8908e6059c 100644 (file)
@@ -184,14 +184,12 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
       "UPDATE Job SET JobStatus='%c',EndTime='%s',"
 "ClientId=%u,JobBytes=%s,ReadBytes=%s,JobFiles=%u,JobErrors=%u,VolSessionId=%u,"
 "VolSessionTime=%u,PoolId=%u,FileSetId=%u,JobTDate=%s,"
-"RealEndTime='%s',PriorJobId=%s,HasBase=%u WHERE JobId=%s",
+"RealEndTime='%s',PriorJobId=%s,HasBase=%u,PurgedFiles=%u WHERE JobId=%s",
       (char)(jr->JobStatus), dt, jr->ClientId, edit_uint64(jr->JobBytes, ed1),
       edit_uint64(jr->ReadBytes, ed4),
       jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime,
       jr->PoolId, jr->FileSetId, edit_uint64(JobTDate, ed2), 
-      rdt,
-      PriorJobId,
-      jr->HasBase,
+      rdt, PriorJobId, jr->HasBase, jr->PurgedFiles,
       edit_int64(jr->JobId, ed3));
 
    stat = UPDATE_DB(jcr, mdb, mdb->cmd);
index 241f9071f872525b4eea1ed6c8d7c22935797710..8f1c1faec41b8e6dd0cd48d01473854cda8e269d 100644 (file)
@@ -527,9 +527,9 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
             }
          }
          /* Create Client record if not already there */
-            bstrncpy(cr.Name, label.ClientName, sizeof(cr.Name));
-            create_client_record(db, &cr);
-            jr.ClientId = cr.ClientId;
+         bstrncpy(cr.Name, label.ClientName, sizeof(cr.Name));
+         create_client_record(db, &cr);
+         jr.ClientId = cr.ClientId;
 
          /* process label, if Job record exists don't update db */
          mjcr = create_job_record(db, &jr, &label, rec);
@@ -1138,6 +1138,9 @@ static int update_job_record(B_DB *db, JOB_DBR *jr, SESSION_LABEL *elabel,
    jr->JobStatus = elabel->JobStatus;
    mjcr->JobStatus = elabel->JobStatus;
    jr->JobFiles = elabel->JobFiles;
+   if (jr->JobFiles > 0) {  /* If we found files, force PurgedFiles */
+      jr->PurgedFiles = 0;
+   }
    jr->JobBytes = elabel->JobBytes;
    jr->VolSessionId = rec->VolSessionId;
    jr->VolSessionTime = rec->VolSessionTime;