about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2017-06-08 13:40:11 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-06-08 13:40:11 +0200
commitf741673638e11e53cd65c70dc5b266735357ad14 (patch)
tree50411a6bbc99e1c38561c02194a78335f3cc572a /app/services
parent0a0b9a271a8de84272ff2dafc96ef53db224bb21 (diff)
Fixes #3605 by returning account from database in case of race condition (#3606)
Diffstat (limited to 'app/services')
-rw-r--r--app/services/follow_remote_account_service.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/services/follow_remote_account_service.rb b/app/services/follow_remote_account_service.rb
index 1e8a53c2d..8558e6d02 100644
--- a/app/services/follow_remote_account_service.rb
+++ b/app/services/follow_remote_account_service.rb
@@ -61,8 +61,13 @@ class FollowRemoteAccountService < BaseService
     account.uri     = get_account_uri(xml)
     account.hub_url = hubs.first.attribute('href').value
 
-    account.save!
-    get_profile(body, account)
+    begin
+      account.save!
+      get_profile(body, account)
+    rescue ActiveRecord::RecordNotUnique
+      # The account has been added by another worker!
+      return Account.find_remote(confirmed_username, confirmed_domain)
+    end
 
     account
   end