Permalink
Browse files

Rescuing ActiveRecord::RecordNotFound in Workers

  • Loading branch information...
1 parent eac16a8 commit 825f7c276d55a7fba3bf68c48d4e500755ab84ed @joelmoss committed Apr 4, 2012
@@ -3,7 +3,11 @@ class CapExecute
include Sidekiq::Worker
def perform(job_id)
- job = Job.find(job_id)
+ begin
+ job = Job.find(job_id)
+ rescue ActiveRecord::RecordNotFound
+ return
+ end
# Make sure the local repo is up to date.
Project::PullRepo.perform(job.project.id) unless job.project.pull_in_progress?
@@ -3,7 +3,12 @@ class CloneRepo
include Sidekiq::Worker
def perform(project_id)
- project = Project.find(project_id)
+ begin
+ project = Project.find(project_id)
+ rescue ActiveRecord::RecordNotFound
+ return
+ end
+
project.update_column :pull_in_progress, true
Strano::Repo.clone project.url
@@ -7,7 +7,12 @@ def self.perform(project_id)
end
def perform(project_id)
- project = Project.find(project_id)
+ begin
+ project = Project.find(project_id)
+ rescue ActiveRecord::RecordNotFound
+ return
+ end
+
project.update_column :pull_in_progress, true
Strano::Repo.pull project.url
@@ -3,7 +3,11 @@ class RemoveRepo
include Sidekiq::Worker
def perform(project_id)
- Strano::Repo.remove Project.unscoped.find(project_id).url
+ begin
+ Strano::Repo.remove Project.unscoped.find(project_id).url
+ rescue ActiveRecord::RecordNotFound
+ return
+ end
end
end
end

0 comments on commit 825f7c2

Please sign in to comment.