]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/bweb/lib/Bweb.pm
ebl fix javascript
[bacula/bacula] / gui / bweb / lib / Bweb.pm
index 1b2d1deb5ed6a43fe60060150be047b159cd21c5..d04a8b9e23e845db155fee31f53eeca1b12914f6 100644 (file)
@@ -52,7 +52,6 @@ package Bweb::Gui;
 
 use HTML::Template;
 our $template_dir='/usr/share/bweb/tpl';
-our $config_file='/etc/bacula/bweb.conf';
 
 =head1 FUNCTION
 
@@ -208,7 +207,7 @@ use CGI;
 our %k_re = ( dbi      => qr/^(dbi:(Pg|mysql):(?:\w+=[\w\d\.-]+;?)+)$/i,
              user     => qr/^([\w\d\.-]+)$/i,
              password => qr/^(.*)$/i,
-             fv_write_path => qr!^([/\w\d\.-]+)$!,
+             fv_write_path => qr!^([/\w\d\.-]*)$!,
              template_dir => qr!^([/\w\d\.-]+)$!,
              debug    => qr/^(on)?$/,
              email_media => qr/^([\w\d\.-]+@[\d\w\.-]+)$/,
@@ -234,7 +233,7 @@ sub load
 
     unless (open(FP, $self->{config_file}))
     {
-       return $self->error("$self->{config_file} : $!");
+       return $self->error("can't load config_file $self->{config_file} : $!");
     }
     my $f=''; my $tmpbuffer;
     while(read FP,$tmpbuffer,4096)
@@ -1019,6 +1018,8 @@ use base q/Bweb::Gui/;
 use DBI;
 use POSIX qw/strftime/;
 
+our $config_file='/etc/bacula/bweb.conf';
+
 our $cur_id=0;
 
 =head1 VARIABLE
@@ -1183,7 +1184,7 @@ sub connect_db
                                    $self->{info}->{user},
                                    $self->{info}->{password});
 
-       print "Can't connect to your database, see error log\n"
+       $self->error("Can't connect to your database:\n$DBI::errstr\n")
            unless ($self->{dbh});
 
        $self->{dbh}->{FetchHashKeyName} = 'NAME_lc';
@@ -2867,28 +2868,23 @@ sub do_update_media
        $update .= " pool=$arg->{pool} " ;
     }
 
-    $arg->{volretention} ||= 0 ; 
-    if ($arg->{volretention}) {
+    if (defined $arg->{volretention}) {
        $update .= " volretention=\"$arg->{volretention}\" " ;
     }
 
-    $arg->{voluseduration} ||= 0 ; 
-    if ($arg->{voluseduration}) {
+    if (defined $arg->{voluseduration}) {
        $update .= " voluse=\"$arg->{voluseduration}\" " ;
     }
 
-    $arg->{maxvoljobs} ||= 0;
-    if ($arg->{maxvoljobs}) {
+    if (defined $arg->{maxvoljobs}) {
        $update .= " maxvoljobs=$arg->{maxvoljobs} " ;
     }
     
-    $arg->{maxvolfiles} ||= 0;
-    if ($arg->{maxvolfiles}) {
+    if (defined $arg->{maxvolfiles}) {
        $update .= " maxvolfiles=$arg->{maxvolfiles} " ;
     }    
 
-    $arg->{maxvolbytes} ||= 0;
-    if ($arg->{maxvolbytes}) {
+    if (defined $arg->{maxvolbytes}) {
        $update .= " maxvolbytes=$arg->{maxvolbytes} " ;
     }    
 
@@ -3008,6 +3004,16 @@ sub label_barcodes
        return $self->error("Can't find autochanger name");
     }
 
+    my $a = $self->ach_get($arg->{ach});
+    unless ($a) {
+       return $self->error("Can't find autochanger name in configuration");
+    } 
+
+    my $storage = $a->get_drive_name($arg->{drive});
+    unless ($storage) {
+       return $self->error("Can't get your drive name");
+    }
+
     my $slots = '';
     my $t = 300 ;
     if ($arg->{slots}) {
@@ -3018,12 +3024,27 @@ sub label_barcodes
     my $b = new Bconsole(pref => $self->{info}, timeout => $t,log_stdout => 1);
     print "<h1>This command can take long time, be patient...</h1>";
     print "<pre>" ;
-    $b->label_barcodes(storage => $arg->{ach},
+    $b->label_barcodes(storage => $storage,
                       drive => $arg->{drive},
                       pool  => 'Scratch',
                       slots => $slots) ;
     $b->close();
     print "</pre>";
+
+    $self->dbh_do("
+  UPDATE Media 
+       SET LocationId =   (SELECT LocationId 
+                             FROM Location 
+                            WHERE Location = '$arg->{ach}'),
+
+           RecyclePoolId = PoolId
+
+     WHERE Media.PoolId = (SELECT PoolId 
+                             FROM Pool
+                            WHERE Name = 'Scratch')
+       AND (LocationId = 0 OR LocationId IS NULL)
+");
+
 }
 
 sub purge