Update to Archive::Extract 0.32
[p5sagit/p5-mst-13.2.git] / lib / Archive / Extract.pm
index c83f581..ad3be80 100644 (file)
@@ -41,7 +41,7 @@ use vars qw[$VERSION $PREFER_BIN $PROGRAMS $WARN $DEBUG
             $_ALLOW_BIN $_ALLOW_PURE_PERL
          ];
 
-$VERSION            = '0.31_02';
+$VERSION            = '0.32';
 $PREFER_BIN         = 0;
 $WARN               = 1;
 $DEBUG              = 0;
@@ -637,12 +637,19 @@ sub have_old_bunzip2 {
                                  $self->bin_tar, '-tf', '-'] :
                 [$self->bin_tar, @ExtraTarFlags, '-tf', $self->archive];
     
-            ### run the command ###
-            my $buffer = '';
-            unless( scalar run( command => $cmd,
+            ### run the command 
+            ### newer versions of 'tar' (1.21 and up) now print record size
+            ### to STDERR as well if v OR t is given (used to be both). This 
+            ### is a 'feature' according to the changelog, so we must now only
+            ### inspect STDOUT, otherwise, failures like these occur:
+            ### nntp.perl.org/group/perl.cpan.testers/2009/02/msg3230366.html
+            my $buffer  = '';
+            my @out     = run(  command => $cmd,
                                 buffer  => \$buffer,
-                                verbose => $DEBUG )
-            ) {
+                                verbose => $DEBUG );
+
+            ### command was unsuccessful            
+            unless( $out[0] ) { 
                 return $self->_error(loc(
                                 "Error listing contents of archive '%1': %2",
                                 $self->archive, $buffer ));
@@ -665,7 +672,10 @@ sub have_old_bunzip2 {
                                                 \s+ [\d,.]+ \s tape \s blocks
                                             |x ? $1 : $_);
     
-                        } split $/, $buffer;
+                        ### only STDOUT, see above. Sometims, extra whitespace
+                        ### is present, so make sure we only pick lines with
+                        ### a length
+                        } grep { length } map { split $/, $_ } @{$out[3]};     
     
                 ### store the files that are in the archive ###
                 $self->files(\@files);
@@ -1421,7 +1431,7 @@ Set to C<true> to have C<Archive::Extract> prefer commandline tools.
 
 Defaults to C<false>.
 
-=head1 TODO
+=head1 TODO / CAVEATS
 
 =over 4
 
@@ -1430,6 +1440,12 @@ Defaults to C<false>.
 Maybe this module should use something like C<File::Type> to determine
 the type, rather than blindly trust the suffix.
 
+=item Thread safety
+
+Currently, C<Archive::Extract> does a C<chdir> to the extraction dir before
+extraction, and a C<chdir> back again after. This is not necessarily 
+thread safe. See C<rt.cpan.org> bug C<#45671> for details.
+
 =back
 
 =head1 BUG REPORTS