Merge pull request #81 from travis-ci/hh-auth-race-condition
Handle race condition with creating users more nicely
This commit is contained in:
commit
02c10fe7cb
|
@ -210,6 +210,7 @@ class Travis::Api::App
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
|
retried ||= false
|
||||||
user = ::User.find_by_github_id(data['id'])
|
user = ::User.find_by_github_id(data['id'])
|
||||||
info = drop_token ? self.info : self.info(github_oauth_token: token)
|
info = drop_token ? self.info : self.info(github_oauth_token: token)
|
||||||
|
|
||||||
|
@ -225,6 +226,11 @@ class Travis::Api::App
|
||||||
end
|
end
|
||||||
|
|
||||||
user
|
user
|
||||||
|
rescue ActiveRecord::RecordNotUnique
|
||||||
|
unless retried
|
||||||
|
retried = true
|
||||||
|
retry
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user