]> cat aescling's git repositories - mastodon.git/commitdiff
Fixes #3605 by returning account from database in case of race condition (#3606)
authorThibG <thib@sitedethib.com>
Thu, 8 Jun 2017 11:40:11 +0000 (13:40 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Thu, 8 Jun 2017 11:40:11 +0000 (13:40 +0200)
app/services/follow_remote_account_service.rb

index 1e8a53c2d41d0e9809a8b6f66dff42f76b6e7d8b..8558e6d02213cbf4442bf50281facb859d5eb3fd 100644 (file)
@@ -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