diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00f716f..37d86c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest container: - image: crystallang/crystal:0.35.1-alpine + image: crystallang/crystal:0.34.0-alpine steps: - uses: actions/checkout@v2 diff --git a/Dockerfile b/Dockerfile index bcbb011..6ce10b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM crystallang/crystal:0.35.1-alpine AS builder +FROM crystallang/crystal:0.34.0-alpine AS builder WORKDIR /Mango diff --git a/shard.lock b/shard.lock index dc0322a..2d95a6f 100644 --- a/shard.lock +++ b/shard.lock @@ -1,46 +1,46 @@ -version: 2.0 +version: 1.0 shards: ameba: - git: https://github.com/crystal-ameba/ameba.git + github: crystal-ameba/ameba version: 0.12.1 archive: - git: https://github.com/hkalexling/archive.cr.git + github: hkalexling/archive.cr version: 0.2.0 baked_file_system: - git: https://github.com/schovi/baked_file_system.git + github: schovi/baked_file_system version: 0.9.8 clim: - git: https://github.com/at-grandpa/clim.git + github: at-grandpa/clim version: 0.12.0 db: - git: https://github.com/crystal-lang/crystal-db.git + github: crystal-lang/crystal-db version: 0.9.0 exception_page: - git: https://github.com/crystal-loot/exception_page.git + github: crystal-loot/exception_page version: 0.1.4 kemal: - git: https://github.com/kemalcr/kemal.git - version: 0.26.1+git.commit.a8c0f09b858162bd13c96663febef5527b322a32 + github: kemalcr/kemal + version: 0.26.1 kemal-session: - git: https://github.com/kemalcr/kemal-session.git + github: kemalcr/kemal-session version: 0.12.1 kilt: - git: https://github.com/jeromegn/kilt.git + github: jeromegn/kilt version: 0.4.0 radix: - git: https://github.com/luislavena/radix.git + github: luislavena/radix version: 0.3.9 sqlite3: - git: https://github.com/crystal-lang/crystal-sqlite3.git + github: crystal-lang/crystal-sqlite3 version: 0.16.0 diff --git a/shard.yml b/shard.yml index c8ed636..3e489ad 100644 --- a/shard.yml +++ b/shard.yml @@ -8,14 +8,13 @@ targets: mango: main: src/mango.cr -crystal: 0.35.0 +crystal: 0.34.0 license: MIT dependencies: kemal: github: kemalcr/kemal - commit: a8c0f09b858162bd13c96663febef5527b322a32 kemal-session: github: kemalcr/kemal-session sqlite3: diff --git a/src/archive.cr b/src/archive.cr index 98423d1..29dedfb 100644 --- a/src/archive.cr +++ b/src/archive.cr @@ -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 diff --git a/src/logger.cr b/src/logger.cr index b1d02a5..8c049ed 100644 --- a/src/logger.cr +++ b/src/logger.cr @@ -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) diff --git a/src/mangadex/downloader.cr b/src/mangadex/downloader.cr index ba49de3..6a62e59 100644 --- a/src/mangadex/downloader.cr +++ b/src/mangadex/downloader.cr @@ -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