From 2573cb1eaeb256468cdf1199a52ccfab94f27b05 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Fri, 23 Apr 2010 17:53:27 +0200 Subject: [PATCH] Fix #1558 about bscan that doesn't update PurgedFiles on Job records --- bacula/src/cats/sql_get.c | 5 +++-- bacula/src/cats/sql_update.c | 6 ++---- bacula/src/stored/bscan.c | 9 ++++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index 540921ef08..e44dc47d4e 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -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); diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index 7dba22031e..fbfee8db16 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -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); diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 241f9071f8..8f1c1faec4 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -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; -- 2.39.5