fix: fix warnings from deprecations across Crystal versions

This commit is contained in:
Fijxu 2026-10-23 19:33:36 -03:00
parent 6150c01ce2
commit b6efcb7eda
No known key found for this signature in database
GPG Key ID: 32C1DDF333EDA6A4
2 changed files with 8 additions and 2 deletions

View File

@ -14,7 +14,9 @@ end
class Invidious::LogHandler < Kemal::BaseLogHandler
def initialize(@io : IO = STDOUT, @level = LogLevel::Debug, use_color : Bool = true)
Colorize.enabled = use_color
{% if compare_versions(Crystal::VERSION, "1.17.0") <= 0 %}
Colorize.on_tty_only!
{% end %}
end
def call(context : HTTP::Server::Context)

View File

@ -82,7 +82,11 @@ module Invidious::HttpServer
private def dispatch_serve(context, file, file_info, range_header)
if range_header
# an IO is needed for `serve_file_range`
{% if compare_versions(Crystal::VERSION, "1.21.0") <= 0 %}
file = file.is_a?(Bytes) ? IO::Memory.new(file, writeable: false) : file
{% else %}
file = file.is_a?(Bytes) ? IO::Memory.new(file, writable: false) : file
{% end %}
serve_file_range(context, file, range_header, file_info)
else
context.response.headers["Accept-Ranges"] = "bytes"