Skip to content

Commit

Permalink
Improve zip reading
Browse files Browse the repository at this point in the history
  • Loading branch information
artygus committed Mar 13, 2024
1 parent 049f5d7 commit 8ae032c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/gepub/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ def self.parse(io)
package = nil
package_path = nil
book = nil
Zip::InputStream::open(io) {
|zis|
package, package_path = parse_container(zis, files)
Zip::File.open(io) {
|zip_file|
package, package_path = parse_container(zip_file, files)
check_consistency_of_package(package, package_path)
parse_files_into_package(files, package)
book = Book.new(package.path)
Expand Down Expand Up @@ -379,12 +379,12 @@ def ncx_xml
end

private
def self.parse_container(zis, files)
def self.parse_container(zip_file, files)
package_path = nil
package = nil
while entry = zis.get_next_entry
zip_file.each do |entry|
if !entry.directory?
files[entry.name] = zis.read
files[entry.name] = zip_file.read(entry)
case entry.name
when MIMETYPE then
if files[MIMETYPE] != MIMETYPE_CONTENTS
Expand Down

0 comments on commit 8ae032c

Please sign in to comment.