From: Eric Bollengier Date: Mon, 9 Nov 2009 14:00:37 +0000 (+0100) Subject: Optimize SQL to determine file selection with directories. It X-Git-Tag: Release-5.0.0~278 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0a2b00e763f06d667e8b296f77873ddcb4724bf4;p=bacula%2Fbacula Optimize SQL to determine file selection with directories. It is enabled for ascii path. --- diff --git a/gui/bweb/cgi/bresto.pl b/gui/bweb/cgi/bresto.pl index a0b217cb42..9624436a08 100755 --- a/gui/bweb/cgi/bresto.pl +++ b/gui/bweb/cgi/bresto.pl @@ -912,11 +912,21 @@ sub fill_table_for_restore FROM File WHERE FileId IN ($fileid))"; } - # using this is not good because the sql engine doesn't know - # what LIKE will use. It will be better to get Path% in perl - # but it doesn't work with accents... :( foreach my $dirid (@dirid) { - push @union, " + my $p = $bvfs->get_path($dirid); + if ($p =~ m!^[a-z0-9/\-_\s,.;:*={}()\[\]\!?]+$!i) { + push @union, " + (SELECT File.JobId, File.FileIndex, File.FilenameId, File.PathId $FileId + FROM Path JOIN File USING (PathId) + WHERE Path.Path LIKE '$p%' + AND File.JobId IN ($inclause))"; + + } else { + # using this is not good because the sql engine doesn't know + # what LIKE will use. It will be better to get Path% in perl + # but it doesn't work with accents... :( + + push @union, " (SELECT File.JobId, File.FileIndex, File.FilenameId, File.PathId $FileId FROM Path JOIN File USING (PathId) WHERE Path.Path LIKE @@ -924,6 +934,7 @@ sub fill_table_for_restore WHERE PathId = $dirid ) AND File.JobId IN ($inclause))"; + } } return unless scalar(@union);