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 3f97f884fe.
This commit is contained in:
Dan Ungureanu 2021-11-25 16:28:28 +02:00 committed by GitHub
parent 03998e0a29
commit b1844c45c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,24 +52,23 @@ task "themes:install" => :environment do |task, args|
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|
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}'..."
theme.remote_theme.update_from_remote
remote_theme.update_from_remote
if theme.remote_theme.last_error_text.present?
puts "Error updating '#{theme.name}': #{theme.remote_theme.last_error_text}"
exit 1 if fail_stop
end
raise RemoteTheme::ImportError.new(remote_theme.last_error_text) if remote_theme.last_error_text.present?
rescue => e
STDERR.puts "Failed to update '#{theme.name}': #{e}"
STDERR.puts e.backtrace
exit 1 if fail_stop
raise if RailsMultisite::ConnectionManagement.current_db == "default"
end
end
true
end
desc "Update themes & theme components"
@ -78,7 +77,7 @@ task "themes:update" => :environment do
update_themes
else
RailsMultisite::ConnectionManagement.each_connection do
update_themes(fail_stop: false)
update_themes
end
end
end