Closed jiu3bao3 closed 1 year ago
You'd need to be more explicit about "doesn't work well". You say what happens with 1.2.11, but nothing about what happens with 1.2.12.
The phenomenon I've said "doesn't work well' is following.
Before updating zlib1.2.12 , contents of output file 'test.txt' was like following.
Hello World!\n
But after updating zlib to version 1.2.12, contents of output file 'test.txt' was empty(0 byte). Nothing was written in output file.
test.txt
is not the output file. test.zip
is the output file of your example code. Do you mean that test.zip
contains an entry named test.txt
, but if you unzip it, the resulting file is empty?
Sorry, Zip entry 'test.txt' seems to be empty, but just extracting contents of zip failed. I tried to unzip using another unzip tool. which says 'Incorrect Password'.
I ran the program again. Output file named "test.zip" contains a entry named "test.txt". but the password validation failed and could not extract contents of zip entry. I ran the program using different password and tried to extract contents, but I cannot extract a content in the zip file.
irb(main):001:0> require 'zip'
=> true
irb(main):002:1* Zip::OutputStream.open("test.zip", Zip::TraditionalEncrypter.ne
irb(main):002:1* Zip::OutputStream.open("test.zip", Zip::TraditionalEncrypter.ne
w("password")) do |zip|
irb(main):003:1* zip.put_next_entry("test.txt")
irb(main):004:1* zip.print("Hello World!\n")
irb(main):005:0> end
=>
#<Zip::OutputStream:0x00007f654ac81d18
@closed=true,
@comment=nil,
@compressor=#<Zip::NullCompressor:0x00007f654ac819f8>,
@current_entry=nil,
@encrypter=
#<Zip::TraditionalEncrypter:0x00007f654ac82290
@key0=-3078641201,
@key1=233305526,
@key2=-3625664778,
@password="password">,
@entry_set=
#<Zip::EntrySet:0x00007f654ac81b60
@entry_set=
{"test.txt"=>
#<Zip::Entry:0x00007f654ac81818
@comment="",
@compressed_size=27,
@compression_method=8,
@crc=2098519517,
@dirty=false,
@external_file_attributes=2175008768,
@extra={},
@filepath=nil,
@follow_symlinks=false,
@fstype=3,
@ftype=:file,
@gp_flags=9,
@header_signature=33639248,
@internal_file_attributes=1,
@local_header_offset=0,
@local_header_size=38,
@name="test.txt",
@restore_ownership=false,
@restore_permissions=false,
@restore_times=false,
@size=13,
@time=2022-10-07 09:34:43.140955641 +0900,
@unix_gid=nil,
@unix_perms=420,
@unix_uid=nil,
@version=52,
@version_needed_to_extract=20,
@zipfile="test.zip">}>,
@file_name="test.zip",
@output_stream=#<File:test.zip (closed)>>
irb(main):006:0> exit
[root@****** ~]# unzip test.zip
Archive: test.zip
[test.zip] test.txt password:
password incorrect--reenter:
password incorrect--reenter:
skipping: test.txt incorrect password
I'd need to know more about how exactly the new version was integrated with Ruby, but instead of that, please text the next release and report back here if there still is or is not an issue. Thanks.
v.1.2.13 solved this issue. It works well. Thank you very much.
I have updated zlib from 1.2.11 to 1.2.12. After this updating, RubyZip doesn't work well, The following code generates a zip file includeing a empty file named test.txt. In the environment using older version of zlib, the following code generates a zip file including a text file containing the text of "Hello World!"
Ruby Version: 3.1