From f5cdf8b7b6815d36e0ceab2a0728f484a8c5829f Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Wed, 1 Jul 2020 13:21:14 +0000 Subject: [PATCH] Explicitly register supported mime types (#82) --- src/library.cr | 2 ++ src/util.cr | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/library.cr b/src/library.cr index a582089..73e0f13 100644 --- a/src/library.cr +++ b/src/library.cr @@ -536,6 +536,8 @@ class Library def initialize @storage = Storage.default + register_mime_types + @dir = Config.current.library_path @scan_interval = Config.current.scan_interval # explicitly initialize @titles to bypass the compiler check. it will diff --git a/src/util.cr b/src/util.cr index 57d0e9b..7467889 100644 --- a/src/util.cr +++ b/src/util.cr @@ -41,8 +41,6 @@ def send_json(env, json) end def send_attachment(env, path) - MIME.register ".cbz", "application/vnd.comicbook+zip" - MIME.register ".cbr", "application/vnd.comicbook-rar" send_file env, path, filename: File.basename(path), disposition: "attachment" end @@ -164,3 +162,14 @@ def escape_xml(str) '&' => "&", }) end + +def register_mime_types + { + ".zip" => "application/zip", + ".rar" => "application/x-rar-compressed", + ".cbz" => "application/vnd.comicbook+zip", + ".cbr" => "application/vnd.comicbook-rar", + }.each do |k, v| + MIME.register k, v + end +end