mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
DB: Move integrity check to the base.cr file
This commit is contained in:
parent
a6c9b263da
commit
c78f84d5c6
2 changed files with 27 additions and 16 deletions
|
@ -112,22 +112,7 @@ OUTPUT = CONFIG.output.upcase == "STDOUT" ? STDOUT : File.open(CONFIG.output, mo
|
||||||
LOGGER = Invidious::LogHandler.new(OUTPUT, CONFIG.log_level)
|
LOGGER = Invidious::LogHandler.new(OUTPUT, CONFIG.log_level)
|
||||||
|
|
||||||
# Check table integrity
|
# Check table integrity
|
||||||
if CONFIG.check_tables
|
Invidious::Database.check_integrity(CONFIG)
|
||||||
Invidious::Database.check_enum("privacy", PlaylistPrivacy)
|
|
||||||
|
|
||||||
Invidious::Database.check_table("channels", InvidiousChannel)
|
|
||||||
Invidious::Database.check_table("channel_videos", ChannelVideo)
|
|
||||||
Invidious::Database.check_table("playlists", InvidiousPlaylist)
|
|
||||||
Invidious::Database.check_table("playlist_videos", PlaylistVideo)
|
|
||||||
Invidious::Database.check_table("nonces", Nonce)
|
|
||||||
Invidious::Database.check_table("session_ids", SessionId)
|
|
||||||
Invidious::Database.check_table("users", User)
|
|
||||||
Invidious::Database.check_table("videos", Video)
|
|
||||||
|
|
||||||
if CONFIG.cache_annotations
|
|
||||||
Invidious::Database.check_table("annotations", Annotation)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Start jobs
|
# Start jobs
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,32 @@ require "pg"
|
||||||
module Invidious::Database
|
module Invidious::Database
|
||||||
extend self
|
extend self
|
||||||
|
|
||||||
|
# Checks table integrity
|
||||||
|
#
|
||||||
|
# Note: config is passed as a parameter to avoid complex
|
||||||
|
# dependencies between different parts of the software.
|
||||||
|
def check_integrity(cfg)
|
||||||
|
return if !cfg.check_tables
|
||||||
|
Invidious::Database.check_enum("privacy", PlaylistPrivacy)
|
||||||
|
|
||||||
|
Invidious::Database.check_table("channels", InvidiousChannel)
|
||||||
|
Invidious::Database.check_table("channel_videos", ChannelVideo)
|
||||||
|
Invidious::Database.check_table("playlists", InvidiousPlaylist)
|
||||||
|
Invidious::Database.check_table("playlist_videos", PlaylistVideo)
|
||||||
|
Invidious::Database.check_table("nonces", Nonce)
|
||||||
|
Invidious::Database.check_table("session_ids", SessionId)
|
||||||
|
Invidious::Database.check_table("users", User)
|
||||||
|
Invidious::Database.check_table("videos", Video)
|
||||||
|
|
||||||
|
if cfg.cache_annotations
|
||||||
|
Invidious::Database.check_table("annotations", Annotation)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Table/enum integrity checks
|
||||||
|
#
|
||||||
|
|
||||||
def check_enum(enum_name, struct_type = nil)
|
def check_enum(enum_name, struct_type = nil)
|
||||||
return # TODO
|
return # TODO
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue