]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/brestore/brestore.pl
bacula-web: Improved smarty code in header for catalog selection
[bacula/bacula] / gui / brestore / brestore.pl
index edb27f128b2c55157735c4ad49bfe5be7fa90e2a..eac4a0fff5e25eb05997e7b806c82692835a341b 100755 (executable)
@@ -65,10 +65,6 @@ my $glade_file = 'brestore.glade' ;
 
 =cut
 
-use Gtk2;              # auto-initialize Gtk2
-use Gtk2::GladeXML;
-use Gtk2::SimpleList;          # easy wrapper for list views
-use Gtk2::Gdk::Keysyms;                # keyboard code constants
 use Data::Dumper qw/Dumper/;
 my $debug=0;                   # can be on brestore.conf
 our ($VERSION) = ('$Revision$' =~ /(\d+)/);
@@ -87,7 +83,7 @@ sub new
        bconsole => 'bconsole', # path and arg to bconsole
        bsr_dest => '',         # destination url for bsr files
        debug    => 0,          # debug level 0|1
-       use_ok_bkp_only => 1,   # dont use bad backup
+       use_ok_bkp_only => 1,   # don't use bad backup
        bweb     => 'http://localhost/cgi-bin/bweb/bweb.pl', # bweb url
        see_all_versions => 0,  # display all file versions in FileInfo
        mozilla  => 'mozilla',  # mozilla bin
@@ -1983,7 +1979,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 +2145,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 +2253,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");
                        }
@@ -2397,6 +2393,9 @@ sub update_cache
 
     $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("
@@ -2740,6 +2739,7 @@ sub get_all_file_versions
    AND File.FileIndex >= JobMedia.FirstIndex
    AND File.FileIndex <= JobMedia.LastIndex
    AND JobMedia.MediaId = Media.MediaId
+   AND Job.Type = 'B'
    AND Client.Name = '$client'";
        
     $self->debug($query);
@@ -3275,7 +3275,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,
@@ -3283,6 +3283,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) {
@@ -3300,6 +3305,14 @@ if ($batch_mod) {
     exit (0);
 }
 
+# load Gtk libraries only in non batch mode
+eval "
+ use Gtk2;
+ use Gtk2::GladeXML;
+ use Gtk2::SimpleList;
+ use Gtk2::Gdk::Keysyms;
+";
+
 $glade_file = $p->{glade_file} || $glade_file;
 
 foreach my $path ('','.','/usr/share/brestore','/usr/local/share/brestore') {