--- a/bin/imager.check Wed Aug 17 09:33:59 2011 +0200
+++ b/bin/imager.check Wed Aug 17 12:10:20 2011 +0200
@@ -11,8 +11,7 @@
use File::Basename;
use autodie qw(:all);
use Cwd qw(abs_path);
-use IO::Compress::Gzip qw(&gzip $GzipError Z_BEST_SPEED);
-use IO::Uncompress::Gunzip qw(&gunzip $GunzipError);
+use Imager;
use Getopt::Long;
use constant CIPHER => "aes-128-cbc";
@@ -20,7 +19,7 @@
sub purge_unused;
sub check_images;
-my %o = (
+our %o = (
yes => undef,
verbose => 1,
checksum => undef,
@@ -226,26 +225,7 @@
next if not $o{checksum};
# checking the checksum
- my $buffer;
- given ($file) {
- when (/\.gz\.x$/) {
- open(
- my $fh =>
- "openssl @{[CIPHER]} -d -pass $o{pass} -in $file|");
- local $/ = undef;
- gunzip($fh => \$buffer) or die $GunzipError;
- }
- when (/\.gz$/) { gunzip($file => \$buffer) or die $GunzipError }
- when (/\.x$/) {
- open(
- my $fh =>
- "openssl @{[CIPHER]} -d -pass $o{pass} -in $file|");
- local $/ = undef;
- $buffer = <$fh>;
- }
- default { open(my $fh => $file); local $/ = undef; $buffer = <$fh> }
- }
-
+ Imager::get_block($file => \my $buffer);
next if md5_hex($buffer) eq basename($file, qw(.gz .x .gz.x));
say "wrong checksum for $file\n";
@invalid{@$i} = ();