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:
parent
c481f2ce16
commit
c0ec1e931e
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue