]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Small change in bdb_get_file_record()
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Wed, 29 Dec 2021 14:56:29 +0000 (15:56 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:57 +0000 (13:56 +0200)
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.

bacula/src/cats/sql_get.c
bacula/src/cats/sql_list.c

index c81657ed9ac41528c6676b8ba7c537728808f3fe..0b1697fbb27d3535297d45d8297cca2c993cc638 100644 (file)
@@ -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);
index 8b5985bec92fc32c61ed721e64663c1940edcf69..2c217378167ddca6ffa4661e6722c556fe9a1a99 100644 (file)
@@ -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 "