mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -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}'..."
|
puts "Updating '#{theme.name}' for '#{RailsMultisite::ConnectionManagement.current_db}'..."
|
||||||
theme.remote_theme.update_from_remote
|
theme.remote_theme.update_from_remote
|
||||||
theme.save!
|
|
||||||
unless theme.remote_theme.last_error_text.nil?
|
if theme.remote_theme.last_error_text.present?
|
||||||
puts "Error updating '#{theme.name}': #{theme.remote_theme.last_error_text}"
|
puts "Error updating '#{theme.name}': #{theme.remote_theme.last_error_text}"
|
||||||
end
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user