]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/brestore/brestore.pl
ebl Choose the right pool&level when try to run a job
[bacula/bacula] / gui / brestore / brestore.pl
index 31359ab54206c26370b8ed54a09bbec9f131cd68..52d36d56ea77c6c31e2177fa56bda4aa1fe01c4a 100755 (executable)
@@ -1983,7 +1983,7 @@ sub create_filelist
 SELECT Job.JobId, Job.VolsessionId, Job.VolsessionTime, JobMedia.StartFile, 
        JobMedia.EndFile, JobMedia.FirstIndex, JobMedia.LastIndex,
        JobMedia.StartBlock, JobMedia.EndBlock, JobMedia.VolIndex, 
-       Media.Volumename, Media.MediaType
+       Media.VolumeName, Media.MediaType
 FROM Job, JobMedia, Media
 WHERE Job.JobId = JobMedia.JobId
   AND JobMedia.MediaId = Media.MediaId
@@ -2149,7 +2149,7 @@ WHERE Job.JobId = JobMedia.JobId
        # path, volsessiontime DESC (get the most recent file...)
        # The array rows look like this :
        # complete_path,is_dir,fileindex,
-       #\81 ref->(jobid,VolsessionId,VolsessionTime,File,FirstIndex,
+       # ref->(jobid,VolsessionId,VolsessionTime,File,FirstIndex,
        #       LastIndex,StartBlock-EndBlock,VolIndex,Volumename,MediaType)
        @temp_list = sort {$a->[0] cmp $b->[0]
                         || $b->[3]->[2] <=> $a->[3]->[2]
@@ -2257,11 +2257,11 @@ WHERE Job.JobId = JobMedia.JobId
                       or $prev_volfile ne $volfile)
                {
                        # We have to create a new section in the bsr...
-                       #\81Â\81 We print the previous one ... 
+                       # We print the previous one ... 
                        # (before that, save the current range ...)
                        if ($first_of_current_range != $prev_fileindex)
                        {
-                               #\81Â\81 we are in a range
+                               # we are in a range
                                push @fileindex_ranges,
                                    ("$first_of_current_range-$prev_fileindex");
                        }
@@ -2392,11 +2392,14 @@ sub update_cache
 
     my $query = "
   SELECT JobId from Job 
-   WHERE JobId NOT IN (SELECT JobId FROM brestore_knownjobid) ORDER BY JobId";
+   WHERE JobId NOT IN (SELECT JobId FROM brestore_knownjobid) AND JobStatus IN ('T', 'f', 'A') ORDER BY JobId";
     my $jobs = $self->dbh_selectall_arrayref($query);
 
     $self->update_brestore_table(map { $_->[0] } @$jobs);
 
+    $self->{conf}->{dbh}->commit();
+    $self->{conf}->{dbh}->begin_work();
+
     print STDERR "Cleaning path visibility\n";
     
     my $nb = $self->dbh_do("
@@ -2879,32 +2882,6 @@ sub update_brestore_table
     }
 }
 
-sub cleanup_brestore_table
-{
-    my ($self) = @_;
-
-    my $query = "SELECT JobId from brestore_knownjobid";
-    my @jobs = @{$self->dbh_selectall_arrayref($query)};
-
-    foreach my $jobentry (@jobs)
-    {
-       my $job = $jobentry->[0];
-       $query = "SELECT FileId from File WHERE JobId = $job LIMIT 1";
-       my $result = $self->dbh_selectall_arrayref($query);
-       if (scalar(@{$result}))
-       {
-           # There are still files for this jobid
-           print STDERR "$job still exists. Not cleaning...\n";
-
-       } else {
-               $query = "DELETE FROM brestore_pathvisibility WHERE JobId = $job";
-               $self->dbh_do($query);
-               $query = "DELETE FROM brestore_knownjobid WHERE JobId = $job";
-               $self->dbh_do($query);
-       }
-    }
-}
-
 sub parent_dir
 {
     my ($path) = @_;
@@ -3301,7 +3278,7 @@ sub HELP_MESSAGE
     exit 1;
 }
 
-my $file_conf = "$ENV{HOME}/.brestore.conf" ;
+my $file_conf = (exists $ENV{HOME})? "$ENV{HOME}/.brestore.conf" : undef ;
 my $batch_mod;
 
 GetOptions("conf=s"   => \$file_conf,
@@ -3309,6 +3286,11 @@ GetOptions("conf=s"   => \$file_conf,
           "debug"    => \$debug,
           "help"     => \&HELP_MESSAGE) ;
 
+if (! defined $file_conf) {
+    print STDERR "Could not detect default config and no config file specified\n";
+    HELP_MESSAGE();
+}
+
 my $p = new Pref($file_conf);
 
 if (! -f $file_conf) {
@@ -3326,7 +3308,7 @@ if ($batch_mod) {
     exit (0);
 }
 
-$glade_file = $p->{glade_file};
+$glade_file = $p->{glade_file} || $glade_file;
 
 foreach my $path ('','.','/usr/share/brestore','/usr/local/share/brestore') {
     if (-f "$path/$glade_file") {