]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/bweb/cgi/bfileview.pl
ebl fix display_job_group, it works now !
[bacula/bacula] / gui / bweb / cgi / bfileview.pl
index ff4086e9a1ff89fec40301711c0bfeb00de65e50..6c07e83aac5cf2094bffcace2b889b1a0d3800ed 100755 (executable)
 
 =cut
 
-# TODO:
-#  Si c'est un fichier selectionne, afficher ses attributs
-#  ajouter le base_fic et base_url dans les options bweb
-#
-
 use strict;
+use POSIX qw/strftime/;
 use Bweb;
 use CCircle ;
 use Digest::MD5 qw(md5_hex);
 use File::Basename qw/basename dirname/;
 
-my $conf = new Bweb::Config(config_file => '/etc/bweb/config');
+my $conf = new Bweb::Config(config_file => $Bweb::config_file);
 $conf->load();
 my $bweb = new Bweb(info => $conf);
 $bweb->connect_db();
@@ -65,9 +61,7 @@ my $md5_rep = md5_hex("$where:$jobid") ;
 my $base_url = '/bweb/fv' ;
 my $base_fich = $conf->{fv_write_path};
 
-die "Can't get where" unless ($where and $jobid);
-
-if ($batch eq 'batch') {
+if ($where and $jobid and $batch eq 'batch') {
     my $root = fv_get_root_pathid($where);
     if ($root) {
        fv_compute_size($jobid, $root);
@@ -80,6 +74,17 @@ print CGI::header('text/html');
 $bweb->display_begin();
 $bweb->display_job_zoom($jobid);
 
+unless ($where and $jobid) {
+    $bweb->error("Can't get where or jobid");
+    exit 0;
+}
+
+unless ($base_fich and -w $base_fich) {
+    $bweb->error("fv_write_path ($base_fich) is not writable." . 
+                " See Bweb configuration.");
+    exit 0;
+}
+
 if (-f "$base_fich/$md5_rep.png" and -f "$base_fich/$md5_rep.tpl")
 {
     $bweb->display({}, "$base_fich/$md5_rep.tpl");
@@ -156,10 +161,11 @@ sub fv_display_rep
        my $size = fv_compute_size($jobid, $dir->[0]);
        $sum += $size;
 
-       my $chld = $ccircle->add_part($size * 100 / $max, 
+       my $per = $size * 100 / $max;
+       my $chld = $ccircle->add_part($per, 
                                      basename($dir->[1]) . '/',
                                      basename($dir->[1]) 
-                                      . "\n" 
+                                      . sprintf(' %.0f%% ', $per)
                                       . Bweb::human_size($size)
                                      ) ;
        
@@ -179,7 +185,7 @@ sub fv_display_rep
 
     if ($sum < $max) {
        $ccircle->add_part(($max - $sum) * 100 / $max, 
-                          "other files < 3",
+                          "other files < 3%",
                           "other\n" . Bweb::human_size($max - $sum));
     }
 
@@ -212,11 +218,7 @@ sub fv_list_dirs
 
     my $ret = $bweb->dbh_selectall_arrayref("
       SELECT P.PathId,
-             (
-              SELECT Path FROM Path WHERE PathId = P.PathId
-              UNION 
-              SELECT Path FROM brestore_missing_path WHERE PathId = P.PathId
-             ) AS Path
+             ( SELECT Path FROM Path WHERE PathId = P.PathId) AS Path
         FROM (
           SELECT PathId
             FROM brestore_pathvisibility 
@@ -237,8 +239,13 @@ sub fv_get_file_attribute
     my $path     = $bweb->dbh_quote(dirname($full_name) . "/");
 
     my $attr = $bweb->dbh_selectrow_hashref("
- SELECT 1 AS found,
-        base64_decode_lstat(8, lstat) AS size
+ SELECT 1    AS found,
+        MD5  AS md5,
+        base64_decode_lstat(8,  LStat) AS size,
+        base64_decode_lstat(11, LStat) AS atime,
+        base64_decode_lstat(12, LStat) AS mtime,
+        base64_decode_lstat(13, LStat) AS ctime
+
    FROM File INNER JOIN Filename USING (FilenameId)
              INNER JOIN Path     USING (PathId)
   WHERE Name  = $filename
@@ -248,6 +255,9 @@ sub fv_get_file_attribute
 
     $attr->{filename} = $full_name;
     $attr->{size} = Bweb::human_size($attr->{size});
+    foreach my $d (qw/atime ctime mtime/) {
+       $attr->{$d} = strftime('%F %H:%M', localtime($attr->{$d}));
+    }
     return $attr;
 }
 
@@ -270,7 +280,7 @@ sub fv_get_files_size
     my ($jobid, $rep) = @_;
 
     my $ret = $bweb->dbh_selectrow_hashref("
- SELECT sum(base64_decode_lstat(8,lstat)) AS size
+ SELECT sum(base64_decode_lstat(8,LStat)) AS size
    FROM File
   WHERE PathId  = $rep
     AND JobId = $jobid
@@ -286,7 +296,7 @@ sub fv_get_big_files
     my $ret = $bweb->dbh_selectall_arrayref("
    SELECT Name, size
    FROM (
-         SELECT FilenameId,base64_decode_lstat(8,lstat) AS size
+         SELECT FilenameId,base64_decode_lstat(8,LStat) AS size
            FROM File
           WHERE PathId  = $rep
             AND JobId = $jobid
@@ -316,11 +326,7 @@ sub fv_get_root_pathid
 {
     my ($path) = @_;
     $path = $bweb->dbh_quote($path);
-    my $ret = $bweb->dbh_selectrow_hashref("
-SELECT PathId FROM Path WHERE Path = $path
-   UNION 
-SELECT PathId FROM brestore_missing_path WHERE PATH = $path
-");
+    my $ret = $bweb->dbh_selectrow_hashref("SELECT PathId FROM Path WHERE Path = $path");
     return $ret->{pathid};
 }
 
@@ -343,4 +349,8 @@ RETURN val;
 END;
 $$ language 'plpgsql';
 
-ALTER TABLE brestore_pathvisibility ADD Size int8;
+ALTER TABLE brestore_pathvisibility ADD Size  int8;
+
+
+
+ALTER TABLE brestore_pathvisibility ADD Files int4;