FIX: Make themes:update work with multisites (#14082)

Running this Rake task in a multisite cluster updated only the default
site.
This commit is contained in:
Dan Ungureanu 2021-08-19 09:41:58 +03:00 committed by GitHub
parent c481f2ce16
commit c0ec1e931e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 5 deletions

View File

@ -52,21 +52,20 @@ task "themes:install" => :environment do |task, args|
end
end
desc "Update themes & theme components"
task "themes:update" => :environment do |task, args|
def update_themes
Theme.where(auto_update: true, enabled: true).find_each do |theme|
begin
if theme.remote_theme.present?
puts "Updating #{theme.name}..."
puts "Updating '#{theme.name}' for '#{RailsMultisite::ConnectionManagement.current_db}'..."
theme.remote_theme.update_from_remote
theme.save!
unless theme.remote_theme.last_error_text.nil?
puts "Error updating #{theme.name}: #{theme.remote_theme.last_error_text}"
puts "Error updating '#{theme.name}': #{theme.remote_theme.last_error_text}"
exit 1
end
end
rescue => e
STDERR.puts "Failed to update #{theme.name}"
STDERR.puts "Failed to update '#{theme.name}'"
STDERR.puts e
STDERR.puts e.backtrace
exit 1
@ -74,6 +73,17 @@ task "themes:update" => :environment do |task, args|
end
end
desc "Update themes & theme components"
task "themes:update" => :environment do
if ENV['RAILS_DB'].present?
update_themes
else
RailsMultisite::ConnectionManagement.each_connection do
update_themes
end
end
end
desc "List all the installed themes on the site"
task "themes:audit" => :environment do
components = Set.new