OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
RakeJob: Load the rake task if it wasn't found
Oliver Güntherb192b97117cb
diff --git a/app/workers/rake_job.rb b/app/workers/rake_job.rbindex ef241461430..1c7525ae98b 100644--- a/app/workers/rake_job.rb+++ b/app/workers/rake_job.rb@@ -28,7 +28,7 @@require "rake"##-# Invoke a rake task while safely loading the tasks only once+# Invoke a rake task while loading the tasks on demand# to ensure they are only loaded once.module RakeJobattr_reader :task_name, :args@@ -44,29 +44,26 @@ module RakeJobprotecteddef invoke- load_tasks!- task.invoke *args- ensure- task&.reenable+ if (task = load_task)+ task.reenable+ task.invoke *args+ else+ OpenProject.logger.error { "Rake task #{task_name} not found for background job." }+ endend##- # Load tasks if there are none. This should only be run once in an environment- def load_tasks!- Rails.application.load_rake_tasks unless tasks_loaded?- end+ # Load tasks if we don't find our task+ def load_task+ Rails.application.load_rake_tasks unless task_loaded?- ##- # Reference to the task name.- # Will raise NameError or NoMethodError depending on what of rake is (not) loaded- def task- Rake::Task[task_name]+ task_loaded? && Rake::Task[task_name]end### Returns whether any task is loaded# Will raise NameError or NoMethodError depending on what of rake is (not) loaded- def tasks_loaded?- !Rake::Task.tasks.empty?+ def task_loaded?+ Rake::Task.task_defined?(task_name)endend