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

View File

@@ -31,9 +31,9 @@ class Logger
{% end %}
@log = Log.for("")
@backend = Log::IOBackend.new
format_proc = ->(entry : Log::Entry, io : IO) do
@backend = Log::IOBackend.new
@backend.formatter = ->(entry : Log::Entry, io : IO) do
color = :default
{% begin %}
case entry.severity.label.to_s().downcase
@@ -50,14 +50,12 @@ class Logger
io << entry.message
end
@backend.formatter = Log::Formatter.new &format_proc
Log.setup @@severity, @backend
Log.builder.bind "*", @@severity, @backend
end
# Ignores @@severity and always log msg
def log(msg)
@backend.write Log::Entry.new "", Log::Severity::None, msg,
Log::Metadata.empty, nil
@backend.write Log::Entry.new "", Log::Severity::None, msg, nil
end
def self.log(msg)

View File

@@ -1,13 +1,13 @@
require "./api"
require "sqlite3"
require "compress/zip"
require "zip"
module MangaDex
class PageJob
property success = false
property url : String
property filename : String
property writer : Compress::Zip::Writer
property writer : Zip::Writer
property tries_remaning : Int32
def initialize(@url, @filename, @writer, @tries_remaning)
@@ -324,7 +324,7 @@ module MangaDex
# Find the number of digits needed to store the number of pages
len = Math.log10(chapter.pages.size).to_i + 1
writer = Compress::Zip::Writer.new zip_path
writer = Zip::Writer.new zip_path
# Create a buffered channel. It works as an FIFO queue
channel = Channel(PageJob).new chapter.pages.size
spawn do