diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-12-16 11:05:49 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-12-16 11:05:49 +0800 |
commit | 16c3a9991961588f43d6d280cc93317d29d242dc (patch) | |
tree | 02c74c7053cca01ce2b723198c6116961e413e17 /staticweb/manbuilder.pl | |
parent | ecd00f1452bbfe0305ff6ce46e1436ba4b9f2bd8 (diff) | |
download | pttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.tar pttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.tar.gz pttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.tar.bz2 pttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.tar.lz pttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.tar.xz pttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.tar.zst pttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.zip |
use Compress::Zlib to save disk space
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1413 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'staticweb/manbuilder.pl')
-rwxr-xr-x | staticweb/manbuilder.pl | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/staticweb/manbuilder.pl b/staticweb/manbuilder.pl index f3b18cf4..3b992a98 100755 --- a/staticweb/manbuilder.pl +++ b/staticweb/manbuilder.pl @@ -7,12 +7,13 @@ use Getopt::Std; use DB_File; use BBSFileHeader; use Data::Serializer; +use Compress::Zlib; my(%db, $idx, $serial); sub main { - die usage() unless( getopts('n') || !@ARGV ); + die usage() unless( getopts('nz') || !@ARGV ); $serial = Data::Serializer->new(serializer => 'Storable', digester => 'MD5', @@ -34,6 +35,7 @@ sub main if( !$Getopt::Std::opt_n ); build("/home/bbs/man/boards/".substr($_, 0, 1)."/$_", ''); $db{_buildtime} = time(); + $db{_gzip} = 1 if( $Getopt::Std::opt_z ); untie %db; } } @@ -41,9 +43,13 @@ sub main sub buildidx { + my $gzipped = $db{_gzip}; foreach( keys %db ){ next if( /^title/ || /\/$/ ); # 是 title 或目錄的都跳過 - $idx->insert($_, $db{"title-$_"}. "\n". $db{$_}); + $idx->insert($_, + ($db{"title-$_"}. "\n". + ($gzipped ? Compress::Zlib::memGunzip($db{$_}) : + $db{$_}))); } } @@ -69,7 +75,8 @@ sub build($$) my $c = $bfh{"$_.content"}; $idx->insert("$doffset/$fn", $bfh{"$_.title"}. "\n$c") if( !$Getopt::Std::opt_n ); - $db{"$doffset/$fn"} = $c; + $db{"$doffset/$fn"} = ($Getopt::Std::opt_z ? + Compress::Zlib::memGzip($c) : $c); } } $db{"$doffset/"} = $serial->serialize(\@tdir); |