DEV: Fail stop if theme update fails (#15074)
This applies only when a single site exists. If a theme update fails when there are multiple sites, then it will continue updating the remaining themes.
This commit is contained in:
parent
59e0ed8820
commit
3f97f884fe
|
@ -52,20 +52,22 @@ task "themes:install" => :environment do |task, args|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_themes
|
def update_themes(fail_stop: true)
|
||||||
Theme.where(auto_update: true, enabled: true).find_each do |theme|
|
Theme.includes(:remote_theme).where(enabled: true, auto_update: true).find_each do |theme|
|
||||||
begin
|
begin
|
||||||
if theme.remote_theme.present?
|
next if theme.remote_theme.blank?
|
||||||
puts "Updating '#{theme.name}' for '#{RailsMultisite::ConnectionManagement.current_db}'..."
|
|
||||||
theme.remote_theme.update_from_remote
|
puts "Updating '#{theme.name}' for '#{RailsMultisite::ConnectionManagement.current_db}'..."
|
||||||
theme.save!
|
theme.remote_theme.update_from_remote
|
||||||
unless theme.remote_theme.last_error_text.nil?
|
|
||||||
puts "Error updating '#{theme.name}': #{theme.remote_theme.last_error_text}"
|
if theme.remote_theme.last_error_text.present?
|
||||||
end
|
puts "Error updating '#{theme.name}': #{theme.remote_theme.last_error_text}"
|
||||||
|
exit 1 if fail_stop
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
STDERR.puts "Failed to update '#{theme.name}': #{e}"
|
STDERR.puts "Failed to update '#{theme.name}': #{e}"
|
||||||
STDERR.puts e.backtrace
|
STDERR.puts e.backtrace
|
||||||
|
exit 1 if fail_stop
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -76,7 +78,7 @@ task "themes:update" => :environment do
|
||||||
update_themes
|
update_themes
|
||||||
else
|
else
|
||||||
RailsMultisite::ConnectionManagement.each_connection do
|
RailsMultisite::ConnectionManagement.each_connection do
|
||||||
update_themes
|
update_themes(fail_stop: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue