New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added better support for windows mingw users #25

Merged
merged 4 commits into from Feb 7, 2012

Conversation

Projects
None yet
2 participants
@2potatocakes
Contributor

2potatocakes commented Feb 6, 2012

Hi Alan/Alex,

Had been running into a couple of problems since bumping a windows project I work on up to ruby1.8.7mingw recently. There were about 14 broken tests when I first got the tests running. Have fixed the majority of them I think, there's still 3 left, but the 3 remaining I believe are for legitimate reasons..

  1. Error:
    test_rename(ZipFileTest):
    Zlib::DataError: invalid stored block lengths
    ../lib/zip/inflater.rb:42:in inflate' ../lib/zip/inflater.rb:42:ininternal_produce_input'
    ../lib/zip/inflater.rb:14:in sysread' ../lib/zip/zip_input_stream.rb:106:insysread'
    ../lib/zip/ioextras.rb:59:in read' ../lib/zip/zip_file.rb:150:inread'
    ../lib/zip/zip_entry.rb:502:in get_input_stream' ../lib/zip/zip_file.rb:125:inget_input_stream'
    ../lib/zip/zip_file.rb:150:in read' C:/code/GitHub/rubyzip/test/ziptest.rb:1239:intest_rename'

  2. Error:
    test_replace(ZipFileTest):
    Zlib::DataError: invalid stored block lengths
    ../lib/zip/inflater.rb:42:in inflate' ../lib/zip/inflater.rb:42:ininternal_produce_input'
    ../lib/zip/inflater.rb:14:in sysread' ../lib/zip/zip_input_stream.rb:106:insysread'
    ../lib/zip/ioextras.rb:59:in read' C:/code/GitHub/rubyzip/test/ziptest.rb:1312:intest_replace'
    ../lib/zip/zip_entry.rb:502:in get_input_stream' ../lib/zip/zip_file.rb:125:inget_input_stream'
    C:/code/GitHub/rubyzip/test/ziptest.rb:1312:in `test_replace'

  3. Failure:
    test_put_next_entry(ZipOutputStreamTest) [C:/code/GitHub/rubyzip/test/ziptest.rb:686]:
    is not true.

95 tests, 933 assertions, 1 failures, 2 errors

I've narrowed down the problem a bit.. If I just take a fresh copy of 5entry.zip I can unzip its contents to a local windows directory fine and all the files within it are fine also. If I then take that exact same zip file and run the following:

require 'zip/zip'
zf = Zip::ZipFile.new("5entry.zip")
zf.rename("data/generated/longAscii.txt", "data/generated/longAscii2.txt")
zf.close

The file is now corrupt and will not extract properly anymore. I've spent a few hours trying to figure out why but I'm a bit stumped? Have you guys got any ideas? If I try and re-open it with your gem at this point, it chokes on the zlib inflater method with the same error as in the tests above if that helps.

Apologies about the syntax changes in the pull request also. I can remove them if you'd prefer? Let me know if you'd like me to change anything and I will.

Kind Regards,
Lucas

@simonoff

This comment has been minimized.

Show comment
Hide comment
@simonoff

simonoff Feb 7, 2012

Member

I will look on it on this week.

Member

simonoff commented Feb 7, 2012

I will look on it on this week.

simonoff added a commit that referenced this pull request Feb 7, 2012

Merge pull request #25 from 2potatocakes/master
Added better support for windows mingw users
Need more testing on windows.

@simonoff simonoff merged commit 5d0b4db into rubyzip:master Feb 7, 2012

@simonoff

This comment has been minimized.

Show comment
Hide comment
@simonoff

simonoff Feb 7, 2012

Member

OK, on mac and linux test works fine.
So you fix your issues or not?

Member

simonoff commented Feb 7, 2012

OK, on mac and linux test works fine.
So you fix your issues or not?

@2potatocakes

This comment has been minimized.

Show comment
Hide comment
@2potatocakes

2potatocakes Feb 7, 2012

Contributor

I don't use the rename method for anything in my actual application so the gem works fine for everything I need.
I just thought you guys should know about it.
The bug still exists on mingw though, I looked at it briefly the other day but couldn't see where the problem was coming from.
I'll have another look later today and let you know what I find.

Contributor

2potatocakes commented Feb 7, 2012

I don't use the rename method for anything in my actual application so the gem works fine for everything I need.
I just thought you guys should know about it.
The bug still exists on mingw though, I looked at it briefly the other day but couldn't see where the problem was coming from.
I'll have another look later today and let you know what I find.

@2potatocakes

This comment has been minimized.

Show comment
Hide comment
@2potatocakes

2potatocakes Feb 8, 2012

Contributor

..sorry alex.. it's nothing to do with the rename method.. it's the 5entry.zip file itself..

It's not a bug within the rubyzip gem, apologies.. I just tested it with some other zip files and it works fine. The problem is coming from the way the test files within 5entry.zip are being generated in the gentestfiles.rb
Windows doesn't like them for some reason.
I can fix it if you want? Not sure it's worth it though really..

Contributor

2potatocakes commented Feb 8, 2012

..sorry alex.. it's nothing to do with the rename method.. it's the 5entry.zip file itself..

It's not a bug within the rubyzip gem, apologies.. I just tested it with some other zip files and it works fine. The problem is coming from the way the test files within 5entry.zip are being generated in the gentestfiles.rb
Windows doesn't like them for some reason.
I can fix it if you want? Not sure it's worth it though really..

@simonoff

This comment has been minimized.

Show comment
Hide comment
@simonoff

simonoff Feb 8, 2012

Member

How I can reproduce this bug?
I'm not familiar with Windows, so please provide more info for me.

Member

simonoff commented Feb 8, 2012

How I can reproduce this bug?
I'm not familiar with Windows, so please provide more info for me.

@2potatocakes

This comment has been minimized.

Show comment
Hide comment
@2potatocakes

2potatocakes Feb 8, 2012

Contributor

To reproduce.. This is my current environment:
Win7-64bit
Ruby 1.8.7
rubygems 1.8.15

Get a copy of zip.exe (Basically a windows version of Info-Zip) from here http://stahlworks.com/dev/zip.exe
Copy it to a local windows directory and then add the path to the zip.exe to the windows PATH environment variable

Then just run:

ruby c:/rubyzip/test/gentestfiles.rb

This generates the 5entry.zip file now located at c:/rubyzip/test/data/generated/5entry.zip

If you try extracting the files from the zip at this point, it works correctly and everything extracts properly.
Now on the command line change into this directory and run IRB:

cd c:/rubyzip/test/data/generated
irb
require 'zip/zip'
zf = Zip::ZipFile.new("5entry.zip")
zf.rename("data/generated/longAscii.txt", "data/generated/longAscii2.txt")
zf.close
exit

Now try extracting that same zip file and you'll find that the file is now corrupt and won't extract properly anymore?

Contributor

2potatocakes commented Feb 8, 2012

To reproduce.. This is my current environment:
Win7-64bit
Ruby 1.8.7
rubygems 1.8.15

Get a copy of zip.exe (Basically a windows version of Info-Zip) from here http://stahlworks.com/dev/zip.exe
Copy it to a local windows directory and then add the path to the zip.exe to the windows PATH environment variable

Then just run:

ruby c:/rubyzip/test/gentestfiles.rb

This generates the 5entry.zip file now located at c:/rubyzip/test/data/generated/5entry.zip

If you try extracting the files from the zip at this point, it works correctly and everything extracts properly.
Now on the command line change into this directory and run IRB:

cd c:/rubyzip/test/data/generated
irb
require 'zip/zip'
zf = Zip::ZipFile.new("5entry.zip")
zf.rename("data/generated/longAscii.txt", "data/generated/longAscii2.txt")
zf.close
exit

Now try extracting that same zip file and you'll find that the file is now corrupt and won't extract properly anymore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment