From: Michal Rakowski Date: Wed, 29 Dec 2021 14:56:29 +0000 (+0100) Subject: Small change in bdb_get_file_record() X-Git-Tag: Beta-15.0.0~675 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f29ce7db058d36c8581004d951c4cfdcb8e65578;p=thirdparty%2Fbacula.git Small change in bdb_get_file_record() This is needed, because when Plugin update it's file attributes during backup, two file records for the same JobId are generated. To display only the newest one (the one having the most recent attributes) in the restore menu, we need to take with the highest DeltaSeq value. --- diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index c81657ed9a..0b1697fbb2 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -126,7 +126,7 @@ bool BDB::bdb_get_file_record(JCR *jcr, JOB_DBR *jr, FILE_DBR *fdbr) if (fdbr->PathId && fdbr->Filename) { Mmsg(cmd, "SELECT FileId, LStat, MD5, FileIndex FROM File WHERE File.JobId=%s AND File.PathId=%s AND " - "File.Filename='%s'", + "File.Filename='%s' ORDER BY DeltaSeq DESC LIMIT 1", edit_int64(fdbr->JobId, ed1), edit_int64(fdbr->PathId, ed2), fdbr->Filename); diff --git a/bacula/src/cats/sql_list.c b/bacula/src/cats/sql_list.c index 8b5985bec9..2c21737816 100644 --- a/bacula/src/cats/sql_list.c +++ b/bacula/src/cats/sql_list.c @@ -1067,6 +1067,9 @@ void BDB::bdb_list_files_for_job(JCR *jcr, JobId_t jobid, int deleted, DB_LIST_H ") AS F JOIN Path ON (Path.PathId=F.PathId) %s %s", edit_int64(jobid, ed1), opt, ed1, join, where); } else { + /* Note: For some files with attributes update may be listed twice here. + * We may consider adding 'DISTICT' to the query, but since it could + * make query much longer it would be nice to handle it in some different way. */ Mmsg(cmd, "SELECT Path.Path||F.Filename AS Filename " "FROM (SELECT PathId, Filename, JobId FROM File WHERE JobId=%s %s" "UNION ALL "