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:
Alex Ling
2020-06-20 16:17:29 +00:00
parent 899b221842
commit 0035cd9177
7 changed files with 34 additions and 37 deletions

View File

@@ -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