mirror of
https://github.com/hkalexling/Mango.git
synced 2026-04-05 00:00:44 -04:00
Revert "Upgrade Crystal to 0.35.1"
Kemal is having some issues in 0.35.0: https://github.com/kemalcr/kemal/issues/575
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
require "compress/zip"
|
||||
require "zip"
|
||||
require "archive"
|
||||
|
||||
# A unified class to handle all supported archive formats. It uses the
|
||||
# Compress::Zip module in crystal standard library if the target file is a
|
||||
# zip archive. Otherwise it uses `archive.cr`.
|
||||
# A unified class to handle all supported archive formats. It uses the ::Zip
|
||||
# module in crystal standard library if the target file is a zip archive.
|
||||
# Otherwise it uses `archive.cr`.
|
||||
class ArchiveFile
|
||||
def initialize(@filename : String)
|
||||
if [".cbz", ".zip"].includes? File.extname filename
|
||||
@archive_file = Compress::Zip::File.new filename
|
||||
@archive_file = Zip::File.new filename
|
||||
else
|
||||
@archive_file = Archive::File.new filename
|
||||
end
|
||||
@@ -20,16 +20,16 @@ class ArchiveFile
|
||||
end
|
||||
|
||||
def close
|
||||
if @archive_file.is_a? Compress::Zip::File
|
||||
@archive_file.as(Compress::Zip::File).close
|
||||
if @archive_file.is_a? Zip::File
|
||||
@archive_file.as(Zip::File).close
|
||||
end
|
||||
end
|
||||
|
||||
# Lists all file entries
|
||||
def entries
|
||||
ary = [] of Compress::Zip::File::Entry | Archive::Entry
|
||||
ary = [] of Zip::File::Entry | Archive::Entry
|
||||
@archive_file.entries.map do |e|
|
||||
if (e.is_a? Compress::Zip::File::Entry && e.file?) ||
|
||||
if (e.is_a? Zip::File::Entry && e.file?) ||
|
||||
(e.is_a? Archive::Entry && e.info.file?)
|
||||
ary.push e
|
||||
end
|
||||
@@ -37,8 +37,8 @@ class ArchiveFile
|
||||
ary
|
||||
end
|
||||
|
||||
def read_entry(e : Compress::Zip::File::Entry | Archive::Entry) : Bytes?
|
||||
if e.is_a? Compress::Zip::File::Entry
|
||||
def read_entry(e : Zip::File::Entry | Archive::Entry) : Bytes?
|
||||
if e.is_a? Zip::File::Entry
|
||||
data = nil
|
||||
e.open do |io|
|
||||
slice = Bytes.new e.uncompressed_size
|
||||
|
||||
Reference in New Issue
Block a user