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.
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);
") 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 "