I'm trying to set the file permissions of files contained in a tarball with the following:
print "Checking $tgz_file... ";
my $edited = 0;
my $tarball = Archive::Tar->new($tgz_file);
my @items = $tarball->get_files();
foreach (@items) {
if ($_->is_dir && $_->mode != 0755) {
$_->mode(0755);
$edited = 1;
} elsif ($_->is_file && $_->mode != 0644) {
$_->mode(0644);
$edited = 1;
}
}
if ($edited) {
$tarball->write($tgz_file, COMPRESS_GZIP);
print "edited!\n";
} else {
print "no changes.\n";
}
But when the write()
method is called, the script dies with the following error:
Out of memory during "large" request for 268439552 bytes, total sbrk() is 313298944 bytes at /usr/lib/perl5/5.10/i686-cygwin/IO/Compress/Adapter/Deflate.pm line 43.
The tarball triggering this error is 22MB (59MB uncompressed), so the numbers above are a little alarming. Am I dealing with a bug in IO::Compress
? Is there some kind of workaround in this case? I'm using perl 5.10.1 for i686-cygwin-thread-multi-64int.