Sfoglia il codice sorgente

Fix the Background Jobs page dying when it finds a non-Agent run job

Akinori MUSHA 9 anni fa
parent
commit
180b694dbd
1 ha cambiato i file con 6 aggiunte e 6 eliminazioni
  1. 6 6
      app/helpers/jobs_helper.rb

+ 6 - 6
app/helpers/jobs_helper.rb

@@ -24,12 +24,12 @@ module JobsHelper
   #
   #
   # Can return nil, or an instance of Agent.
   # Can return nil, or an instance of Agent.
   def agent_from_job(job)
   def agent_from_job(job)
-    begin
-      Agent.find_by_id(YAML.load(job.handler).job_data['arguments'][0])
-    rescue ArgumentError
-      # We can get to this point before all of the agents have loaded (usually,
-      # in development)
-      nil
+    if data = YAML.load(job.handler).try(:job_data)
+      Agent.find_by_id(data['arguments'][0])
     end
     end
+  rescue ArgumentError
+    # We can get to this point before all of the agents have loaded (usually,
+    # in development)
+    nil
   end
   end
 end
 end