mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-17 03:34:29 -05:00
Support Crystal 0.35.0
This commit is contained in:
parent
338dc3223c
commit
d30a972a90
@ -11,13 +11,13 @@ targets:
|
||||
dependencies:
|
||||
pg:
|
||||
github: will/crystal-pg
|
||||
version: ~> 0.21.0
|
||||
version: ~> 0.21.1
|
||||
sqlite3:
|
||||
github: crystal-lang/crystal-sqlite3
|
||||
version: ~> 0.16.0
|
||||
kemal:
|
||||
github: kemalcr/kemal
|
||||
version: ~> 0.26.1
|
||||
branch: master
|
||||
pool:
|
||||
github: ysbaddaden/pool
|
||||
version: ~> 0.2.3
|
||||
@ -28,6 +28,6 @@ dependencies:
|
||||
github: omarroth/lsquic.cr
|
||||
branch: dev
|
||||
|
||||
crystal: 0.34.0
|
||||
crystal: 0.35.0
|
||||
|
||||
license: AGPLv3
|
||||
|
@ -23,7 +23,7 @@ require "pg"
|
||||
require "sqlite3"
|
||||
require "xml"
|
||||
require "yaml"
|
||||
require "zip"
|
||||
require "compress/zip"
|
||||
require "protodec/utils"
|
||||
require "./invidious/helpers/*"
|
||||
require "./invidious/*"
|
||||
@ -2660,7 +2660,7 @@ post "/data_control" do |env|
|
||||
|
||||
PG_DB.exec("UPDATE users SET feed_needs_update = true, subscriptions = $1 WHERE email = $2", user.subscriptions, user.email)
|
||||
when "import_newpipe"
|
||||
Zip::Reader.open(IO::Memory.new(body)) do |file|
|
||||
Compress::Zip::Reader.open(IO::Memory.new(body)) do |file|
|
||||
file.each_entry do |entry|
|
||||
if entry.filename == "newpipe.db"
|
||||
tempfile = File.tempfile(".db")
|
||||
|
@ -74,10 +74,10 @@ class FilteredCompressHandler < Kemal::Handler
|
||||
|
||||
if request_headers.includes_word?("Accept-Encoding", "gzip")
|
||||
env.response.headers["Content-Encoding"] = "gzip"
|
||||
env.response.output = Gzip::Writer.new(env.response.output, sync_close: true)
|
||||
env.response.output = Compress::Gzip::Writer.new(env.response.output, sync_close: true)
|
||||
elsif request_headers.includes_word?("Accept-Encoding", "deflate")
|
||||
env.response.headers["Content-Encoding"] = "deflate"
|
||||
env.response.output = Flate::Writer.new(env.response.output, sync_close: true)
|
||||
env.response.output = Compress::Deflate::Writer.new(env.response.output, sync_close: true)
|
||||
end
|
||||
|
||||
call_next env
|
||||
|
@ -625,6 +625,7 @@ def extract_shelf_items(nodeset, ucid = nil, author_name = nil)
|
||||
end
|
||||
|
||||
def check_enum(db, logger, enum_name, struct_type = nil)
|
||||
return # TODO
|
||||
if !db.query_one?("SELECT true FROM pg_type WHERE typname = $1", enum_name, as: Bool)
|
||||
logger.puts("CREATE TYPE #{enum_name}")
|
||||
|
||||
@ -646,18 +647,14 @@ def check_table(db, logger, table_name, struct_type = nil)
|
||||
end
|
||||
end
|
||||
|
||||
if !struct_type
|
||||
return
|
||||
end
|
||||
return if !struct_type
|
||||
|
||||
struct_array = struct_type.to_type_tuple
|
||||
column_array = get_column_array(db, table_name)
|
||||
column_types = File.read("config/sql/#{table_name}.sql").match(/CREATE TABLE public\.#{table_name}\n\((?<types>[\d\D]*?)\);/)
|
||||
.try &.["types"].split(",").map { |line| line.strip }
|
||||
.try &.["types"].split(",").map { |line| line.strip }.reject &.starts_with?("CONSTRAINT")
|
||||
|
||||
if !column_types
|
||||
return
|
||||
end
|
||||
return if !column_types
|
||||
|
||||
struct_array.each_with_index do |name, i|
|
||||
if name != column_array[i]?
|
||||
@ -708,6 +705,15 @@ def check_table(db, logger, table_name, struct_type = nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return if column_array.size <= struct_array.size
|
||||
|
||||
# column_array.each do |column|
|
||||
# if !struct_array.includes? column
|
||||
# logger.puts("ALTER TABLE #{table_name} DROP COLUMN #{column} CASCADE")
|
||||
# db.exec("ALTER TABLE #{table_name} DROP COLUMN #{column} CASCADE")
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
class PG::ResultSet
|
||||
@ -897,15 +903,35 @@ end
|
||||
|
||||
def proxy_file(response, env)
|
||||
if response.headers.includes_word?("Content-Encoding", "gzip")
|
||||
Gzip::Writer.open(env.response) do |deflate|
|
||||
response.pipe(deflate)
|
||||
Compress::Gzip::Writer.open(env.response) do |deflate|
|
||||
IO.copy response.body_io, deflate
|
||||
end
|
||||
elsif response.headers.includes_word?("Content-Encoding", "deflate")
|
||||
Flate::Writer.open(env.response) do |deflate|
|
||||
response.pipe(deflate)
|
||||
Compress::Deflate::Writer.open(env.response) do |deflate|
|
||||
IO.copy response.body_io, deflate
|
||||
end
|
||||
else
|
||||
response.pipe(env.response)
|
||||
IO.copy response.body_io, env.response
|
||||
end
|
||||
end
|
||||
|
||||
# See https://github.com/kemalcr/kemal/pull/576
|
||||
class HTTP::Server::Response::Output
|
||||
def close
|
||||
return if closed?
|
||||
|
||||
unless response.wrote_headers?
|
||||
response.content_length = @out_count
|
||||
end
|
||||
|
||||
ensure_headers_written
|
||||
|
||||
super
|
||||
|
||||
if @chunked
|
||||
@io << "0\r\n\r\n"
|
||||
@io.flush
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -81,12 +81,12 @@ def send_file(env : HTTP::Server::Context, file_path : String, data : Slice(UInt
|
||||
condition = config.is_a?(Hash) && config["gzip"]? == true && filesize > minsize && Kemal::Utils.zip_types(file_path)
|
||||
if condition && request_headers.includes_word?("Accept-Encoding", "gzip")
|
||||
env.response.headers["Content-Encoding"] = "gzip"
|
||||
Gzip::Writer.open(env.response) do |deflate|
|
||||
Compress::Gzip::Writer.open(env.response) do |deflate|
|
||||
IO.copy(file, deflate)
|
||||
end
|
||||
elsif condition && request_headers.includes_word?("Accept-Encoding", "deflate")
|
||||
env.response.headers["Content-Encoding"] = "deflate"
|
||||
Flate::Writer.open(env.response) do |deflate|
|
||||
Compress::Deflate::Writer.open(env.response) do |deflate|
|
||||
IO.copy(file, deflate)
|
||||
end
|
||||
else
|
||||
|
@ -332,7 +332,7 @@ end
|
||||
def sha256(text)
|
||||
digest = OpenSSL::Digest.new("SHA256")
|
||||
digest << text
|
||||
return digest.hexdigest
|
||||
return digest.final.hexstring
|
||||
end
|
||||
|
||||
def subscribe_pubsub(topic, key, config)
|
||||
|
Loading…
Reference in New Issue
Block a user