mirror of
https://github.com/discourse/discourse.git
synced 2025-06-07 16:16:02 +08:00
DEV: Stop if theme:update fails for default site (#15090)
The error handling of the theme:update Rake task has been improved. If an error occurs while updating the default site, then the exception will be propagated and the process will exit with non-zero status. This is a follow-up to commit 3f97f884fef9d3e4b33ae6361d7891c3c414802b.
This commit is contained in:
@ -52,24 +52,23 @@ task "themes:install" => :environment do |task, args|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_themes(fail_stop: true)
|
def update_themes
|
||||||
Theme.includes(:remote_theme).where(enabled: true, auto_update: true).find_each do |theme|
|
Theme.includes(:remote_theme).where(enabled: true, auto_update: true).find_each do |theme|
|
||||||
begin
|
begin
|
||||||
next if theme.remote_theme.blank?
|
remote_theme = theme.remote_theme
|
||||||
|
next if 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
|
remote_theme.update_from_remote
|
||||||
|
|
||||||
if theme.remote_theme.last_error_text.present?
|
raise RemoteTheme::ImportError.new(remote_theme.last_error_text) if remote_theme.last_error_text.present?
|
||||||
puts "Error updating '#{theme.name}': #{theme.remote_theme.last_error_text}"
|
|
||||||
exit 1 if fail_stop
|
|
||||||
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
|
raise if RailsMultisite::ConnectionManagement.current_db == "default"
|
||||||
exit 1 if fail_stop
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Update themes & theme components"
|
desc "Update themes & theme components"
|
||||||
@ -78,7 +77,7 @@ task "themes:update" => :environment do
|
|||||||
update_themes
|
update_themes
|
||||||
else
|
else
|
||||||
RailsMultisite::ConnectionManagement.each_connection do
|
RailsMultisite::ConnectionManagement.each_connection do
|
||||||
update_themes(fail_stop: false)
|
update_themes
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user