mirror of https://github.com/iv-org/invidious.git
Add check for missing dependency files
This commit is contained in:
parent
392e447969
commit
9c0cb2a513
|
@ -58,27 +58,45 @@ end
|
||||||
# different or the requested dependency just isn't present, then it needs to be
|
# different or the requested dependency just isn't present, then it needs to be
|
||||||
# installed.
|
# installed.
|
||||||
|
|
||||||
# Since we can't know when videojs-youtube-annotations is updated, we'll just always fetch
|
|
||||||
# a new copy each time.
|
|
||||||
dependencies_to_install = [] of String
|
dependencies_to_install = [] of String
|
||||||
|
|
||||||
required_dependencies.keys.each do |dep|
|
required_dependencies.keys.each do |dep|
|
||||||
dep = dep.to_s
|
dep = dep.as_s
|
||||||
path = "assets/videojs/#{dep}"
|
path = "assets/videojs/#{dep}"
|
||||||
|
|
||||||
# Check for missing dependencies
|
# Check for missing dependencies
|
||||||
|
#
|
||||||
|
# Does the directory exist?
|
||||||
|
# Does the Javascript file exist?
|
||||||
|
# Does the CSS file exist?
|
||||||
|
#
|
||||||
|
# videojs-contrib-quality-levels.js is the only dependency that does not come with a CSS file so
|
||||||
|
# we skip the check there
|
||||||
if !Dir.exists?(path)
|
if !Dir.exists?(path)
|
||||||
Dir.mkdir(path)
|
Dir.mkdir(path)
|
||||||
dependencies_to_install << dep
|
next dependencies_to_install << dep
|
||||||
else
|
elsif !(File.exists?("#{path}/#{dep}.js") || File.exists?("#{path}/versions.yml"))
|
||||||
|
next dependencies_to_install << dep
|
||||||
|
elsif dep != "videojs-contrib-quality-levels" && !File.exists?("#{path}/#{dep}.css")
|
||||||
|
next dependencies_to_install << dep
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check if we need to update the dependency
|
||||||
|
|
||||||
config = File.open("#{path}/versions.yml") do |file|
|
config = File.open("#{path}/versions.yml") do |file|
|
||||||
YAML.parse(file).as_h
|
YAML.parse(file).as_h
|
||||||
end
|
end
|
||||||
|
|
||||||
if config["version"].as_s != required_dependencies[dep]["version"].as_s || config["minified"].as_bool != minified
|
if config["version"].as_s != required_dependencies[dep]["version"].as_s || config["minified"].as_bool != minified
|
||||||
`rm -rf #{path}/*.js #{path}/*.css`
|
# Clear directory
|
||||||
dependencies_to_install << dep
|
{"*.js", "*.css"}.each do |file_types|
|
||||||
|
Dir.glob("#{path}/#{file_types}").each do |file_path|
|
||||||
|
File.delete(file_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
dependencies_to_install << dep
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Now we begin the fun part of installing the dependencies.
|
# Now we begin the fun part of installing the dependencies.
|
||||||
|
|
Loading…
Reference in New Issue