X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FSearch.pm;h=f2dac44032b8a661042a284e18dbeedc25c63b8e;hp=43587dcf4e7d334d029d94dc5ff2a979645225cc;hb=1f12f5ba25530a04f3a5e7b86c3ac88d9526fe1d;hpb=34090ca531b2884cc67af016548fed67f398507e diff --git a/lib/BackupPC/Search.pm b/lib/BackupPC/Search.pm index 43587dc..f2dac44 100644 --- a/lib/BackupPC/Search.pm +++ b/lib/BackupPC/Search.pm @@ -12,17 +12,21 @@ use XML::Writer; use IO::File; use Data::Dump qw(dump); +require Exporter; +our @ISA=qw(Exporter); +our @EXPORT=qw(unit); + my $on_page = 100; my $pager_pages = 10; -my $dsn = $Conf{SearchDSN}; -my $db_user = $Conf{SearchUser} || ''; +my $dbh; + +my $bpc = BackupPC::Lib->new || die; +$bpc->ConfigRead('_search_archive'); +my %Conf = $bpc->Conf(); sub search_module { - my $bpc = BackupPC::Lib->new || die; - my %Conf = $bpc->Conf(); - my $search_module = $Conf{SearchModule} || die "search is disabled"; eval "use $search_module"; if ( $@ ) { @@ -37,7 +41,7 @@ sub search_module { my $dbh; sub get_dbh { - $dbh ||= DBI->connect($dsn, $db_user, "", { RaiseError => 1, AutoCommit => 1 } ); + $dbh ||= DBI->connect($Conf{SearchDSN}, $Conf{SearchUser}, "", { RaiseError => 1, AutoCommit => 1 } ); return $dbh; } @@ -300,10 +304,9 @@ sub getGzipName($$$) sub get_tgz_size_by_name($) { my $name = shift; - my $tgz = $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'.$name; + my $tgz = $Conf{GzipTempDir}.'/'.$name; my $size = -1; - my $Dir = $Conf{InstallDir}."/data/log"; $|=1; if (-f "${tgz}.tar.gz") { $size = (stat("${tgz}.tar.gz"))[7]; @@ -374,7 +377,7 @@ sub getGzipSize($$) sub getVolumes($) { my $id = shift; - my $max_archive_size = $Conf{MaxArchiveSize} || die "no MaxArchiveSize"; + my $max_archive_size = $Conf{ArchiveMediaSize} || die "no ArchiveMediaSize"; my $sth = $dbh->prepare(qq{ select @@ -450,13 +453,11 @@ print STDERR "## sort=". ($param->{'sort'} || 'no sort param') . " burn sql orde $row->{'age'} = sprintf("%0.1f", ( $row->{'age'} / 86400 ) ); #$row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) ); - my $max_archive_size = $Conf{MaxArchiveSize} || die "no MaxArchiveSize"; + my $max_archive_size = $Conf{ArchiveMediaSize} || die "no ArchiveMediaSize"; if ($row->{size} > $max_archive_size) { ($row->{volumes}, $row->{inc_size_calc}) = getVolumes($row->{id}); } - $row->{size} = sprintf("%0.2f", $row->{size} / 1024 / 1024); - # do some cluster calculation (approximate) $row->{inc_size} = int(( ($row->{inc_size} + 1023 ) / 2 ) * 2); $row->{inc_size_calc} ||= $row->{inc_size}; @@ -470,8 +471,8 @@ sub displayBackupsGrid($) { my $param = shift; - my $max_archive_size = $Conf{MaxArchiveSize} || die "no MaxArchiveSize"; - my $max_archive_file_size = $Conf{MaxArchiveFileSize} || die "no MaxFileInSize"; + my $max_archive_size = $Conf{ArchiveMediaSize} || die "no ArchiveMediaSize"; + my $max_archive_file_size = $Conf{ArchiveChunkSize} || die "no MaxFileInSize"; my $retHTML .= q{