Skip Menu |
 

This queue is for tickets about the Archive-Zip CPAN distribution.

Report information
The Basics
Id: 7633
Status: open
Priority: 0/
Queue: Archive-Zip

People
Owner: nedkonz [...] cpan.org
Requestors: andybalaam [...] artificialworlds.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.13
Fixed in: (no value)



Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
MIME-Version: 1.0
X-Mailer: MIME-tools 5.411 (Entity 5.404)
Subject: readScalar.pl is failing
X-RT-Original-Encoding: iso-8859-1
Content-Length: 2726
Download (untitled) / with headers
text/plain 2.6k
Using the Archive::Zip 1.13 the readScalar.pl script fails like so: [andy@andy-p4-linux tmp]$ ./readScalar.pl Read 20000 bytes error: file not seekable Archive::Zip::Archive::readFromFileHandle('Archive::Zip::Archive=HASH(0x839e548)','IO::Scalar=GLOB(0x839e554)') called at ./readScalar.pl line 20 The exact code used is below (identical to examples/readScalar.pl from the Archive::Zip package, with a changed filename): #!/usr/bin/perl -w # Demonstrates reading a zip from an IO::Scalar # $Revision: 1.4 $ use strict; use Archive::Zip qw(:CONSTANTS :ERROR_CODES); use IO::Scalar; use IO::File; # test reading from a scalar my $file = IO::File->new('maze-logos.zip', 'r'); my $zipContents; binmode($file); $file->read($zipContents, 20000); $file->close(); printf "Read %d bytes\n", length($zipContents); my $SH = IO::Scalar->new(\$zipContents); my $zip = Archive::Zip->new(); $zip->readFromFileHandle( $SH ); my $member = $zip->addString('c' x 300, 'bunchOfCs.txt'); $member->desiredCompressionMethod(COMPRESSION_DEFLATED); $member = $zip->addString('d' x 300, 'bunchOfDs.txt'); $member->desiredCompressionMethod(COMPRESSION_DEFLATED); $zip->writeToFileNamed('maze-logos2.zip'); ------------------------ The above script fails with all available versions of Archive::Zip, but for version 1.10 and below it has a different error message, and my own script (XMLTV's tv_grab_uk_bleb: http://cvs.sourceforge.net/viewcvs.py/xmltv/xmltv/grab/uk_bleb/tv_grab_uk_bleb.in?rev=1.5&view=markup works fine with version 1.10 and below.) The error message given with version 1.10 and below from readScalar.pl is as follows: [andy@andy-p4-linux tmp]$ ./readScalar.pl Read 20000 bytes format error: can't find EOCD signature Archive::Zip::Archive::_findEndOfCentralDirectory('Archive::Zip::Archive=HASH(0x80cf6f4)','IO::Scalar=GLOB(0x80cf700)') called at /usr/lib/perl5/site_perl/5.8.0/Archive/Zip.pm line 945 Archive::Zip::Archive::readFromFileHandle('Archive::Zip::Archive=HASH(0x80cf6f4)','IO::Scalar=GLOB(0x80cf700)') called at ./readScalar.pl line 20 which looks like a different issue. ---------- Looking at line 49 of Zip.pm; # TODO: how to support non-seekable zips? return _error('file not seekable') unless _isSeekable($fh); this looks like a known issue. --------------- I'd like to do anything I can to help resolve this as this functionality is very useful to me. -------------- System: RedHat 9: [andy@andy-p4-linux andy]$ uname -a Linux andy-p4-linux 2.4.20-20.9 #1 Mon Aug 18 11:45:58 EDT 2003 i686 i686 i386 GNU/Linux [andy@andy-p4-linux andy]$ perl -v This is perl, v5.8.0 built for i386-linux-thread-multi (with 1 registered patch, see perl -V for more detail)
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
MIME-Version: 1.0
X-Mailer: MIME-tools 5.411 (Entity 5.404)
X-RT-Original-Encoding: iso-8859-1
Content-Length: 650
Download (untitled) / with headers
text/plain 650b
Well, since IO::Scalar and IO::String have apparently been seekable since Perl 5.6 (I don't use Perl any more), why not try just changing _isSeekable to have something like: sub _isSeekable # Archive::Zip { my $fh = shift; if ( UNIVERSAL::isa( $fh, 'IO::Scalar' ) ) { return $] >= 5.006; } elsif ( UNIVERSAL::isa( $fh, 'IO::String' ) ) { return $] >= 5.006; } elsif ( UNIVERSAL::can( $fh, 'stat' ) ) { return -f $fh; } return UNIVERSAL::can( $fh, 'seek' ); } I haven't tried this, but you might do so. And of course you can also pass a reference to a string to open() in Perl 5.8; have you tried file handles opened that way?
MIME-Version: 1.0
X-Mailer: MIME-tools 5.411 (Entity 5.404)
From: Andy Balaam
Content-Type: multipart/mixed; boundary="----------=_1095152676-6177-0"
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 170
Download (untitled) / with headers
text/plain 170b
The attached patch does as you suggested, and fixes my problem. Thanks very much. Will you commit the change, or should I do something to make it happen? Thanks, Andy
Content-Type: text/plain; name="diff.txt"
Content-Disposition: inline; filename="diff.txt"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 506
Download diff.txt
text/plain 506b
diff -r -uBb Archive-Zip-1.13/lib/Archive/Zip.pm Archive-Zip-1.13-modified/lib/Archive/Zip.pm --- Archive-Zip-1.13/lib/Archive/Zip.pm 2004-08-23 14:27:39.000000000 +0100 +++ Archive-Zip-1.13-modified/lib/Archive/Zip.pm 2004-09-14 09:59:34.000000000 +0100 @@ -313,11 +313,11 @@ if ( UNIVERSAL::isa( $fh, 'IO::Scalar' ) ) { - return 0; + return $] >= 5.006; } elsif ( UNIVERSAL::isa( $fh, 'IO::String' ) ) { - return 1; + return $] >= 5.006; } elsif ( UNIVERSAL::can( $fh, 'stat' ) ) {
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
MIME-Version: 1.0
X-Mailer: MIME-tools 5.415 (Entity 5.415)
X-RT-Original-Encoding: iso-8859-1
Content-Length: 1014
Download (untitled) / with headers
text/plain 1014b
[NEDKONZ - Mon Sep 13 19:12:36 2004]: Show quoted text
> Well, since IO::Scalar and IO::String have apparently been seekable > since Perl 5.6 (I don't use Perl any more), why not try just changing > _isSeekable to have something like: > > sub _isSeekable # Archive::Zip > { > my $fh = shift; > > if ( UNIVERSAL::isa( $fh, 'IO::Scalar' ) ) > { > return $] >= 5.006; > } > elsif ( UNIVERSAL::isa( $fh, 'IO::String' ) ) > { > return $] >= 5.006; > } > elsif ( UNIVERSAL::can( $fh, 'stat' ) ) > { > return -f $fh; > } > return UNIVERSAL::can( $fh, 'seek' ); > } > > I haven't tried this, but you might do so. > > And of course you can also pass a reference to a string to open() in > Perl 5.8; have you tried file handles opened that way?
I'm, unfortunately, getting the "format error: can't find EOCD signature" error with this patch. I'll back up a few versions to see if this goes away. If it does, I should be able to narrow down the cause very quickly. This should be resolved for the next release.
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
MIME-Version: 1.0
X-Mailer: MIME-tools 5.415 (Entity 5.415)
From: Andy Balaam
X-RT-Original-Encoding: iso-8859-1
Content-Length: 357
Download (untitled) / with headers
text/plain 357b
[SMPETERS - Fri Mar 11 09:34:47 2005]: Show quoted text
> I'm, unfortunately, getting the "format error: can't find EOCD > signature" error with this patch. I'll back up a few versions to see if > this goes away. If it does, I should be able to narrow down the cause > very quickly. This should be resolved for the next release.
Have you made any progress on this?
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-30925-1334848380-800.7633-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 108
Download (untitled) / with headers
text/plain 108b
Trying to clean up some RT tickets here. Is this still an issue? Does the latest revision fix the problem?
From andybalaam [...] artificialworlds.net Thu Apr 19 14: 50:51 2012
CC: SMPETERS [...] cpan.org
MIME-Version: 1.0
X-Spam-Status: No, score=-1.121 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, SPF_NEUTRAL=0.779] autolearn=no
In-Reply-To: <rt-3.8.HEAD-30925-1334848380-1657.7633-6-0 [...] rt.cpan.org>
X-Ironport-Anti-Spam-Result: Av0EAEVdkE9cHhyh/2dsb2JhbABDsUSBCIIKAQU6HCMQCANGLA0eiCy7JI1CgyUElW6BE48pgmg
X-Mailer: Claws Mail 3.7.9 (GTK+ 2.24.6; x86_64-pc-linux-gnu)
X-Spam-Flag: NO
References: <RT-Ticket-7633 [...] rt.cpan.org> <rt-3.8.HEAD-30925-1334848380-1657.7633-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Ironport-Anti-Spam-Filtered: true
Message-ID: <20120419195035.5fc2192a [...] ubuntu-i3>
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -1.121
X-Ironport-Av: E=Sophos;i="4.75,448,1330905600"; d="scan'208";a="388399204"
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 950C82402FA for <cpan-bug+Archive-Zip [...] hipster.bestpractical.com>; Thu, 19 Apr 2012 14:50:51 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O9KftoBBPuDT for <cpan-bug+Archive-Zip [...] hipster.bestpractical.com>; Thu, 19 Apr 2012 14:50:50 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id CF43A2402F2 for <bug-Archive-Zip [...] rt.cpan.org>; Thu, 19 Apr 2012 14:50:49 -0400 (EDT)
Received: (qmail 5486 invoked by uid 103); 19 Apr 2012 18:50:49 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 19 Apr 2012 18:50:49 -0000
Received: from out1.ip01ir2.opaltelecom.net (HELO out1.ip01ir2.opaltelecom.net) (62.24.128.237) by 16.mx.develooper.com (qpsmtpd/0.80/v0.80-19-gf52d165) with ESMTP; Thu, 19 Apr 2012 11:50:45 -0700
Received: from host-92-30-28-161.as13285.net (HELO server-vm) ([92.30.28.161]) by out1.ip01ir2.opaltelecom.net with ESMTP; 19 Apr 2012 19:50:41 +0100
Received: by server-vm (Postfix, from userid 1002) id D168D3FD1; Thu, 19 Apr 2012 18:50:40 +0000 (UTC)
Received: from ubuntu-i3 (unknown [10.0.1.5]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by server-vm (Postfix) with ESMTPSA id 82A791C3B; Thu, 19 Apr 2012 18:50:38 +0000 (UTC)
Delivered-To: cpan-bug+Archive-Zip [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #7633] readScalar.pl is failing
Return-Path: <andybalaam [...] artificialworlds.net>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+Archive-Zip [...] hipster.bestpractical.com
X-RT-Mail-Extension: archive-zip
X-Old-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,BAYES_00 autolearn=unavailable version=3.3.1
Date: Thu, 19 Apr 2012 19:50:35 +0100
X-Old-Spam-Level:
X-Spam-Level:
To: bug-Archive-Zip [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Andy Balaam <andybalaam [...] artificialworlds.net>
RT-Message-ID: <rt-3.8.HEAD-30927-1334861452-130.7633-0-0 [...] rt.cpan.org>
Content-Length: 187
Download (untitled) / with headers
text/plain 187b
I still get the same error when running the same script, with perl v5.12.4 and Archive::Zip 1.30. (on Ubuntu 12.04) I also still get the same error when running examples/readScalar.pl


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.