about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-03-16 20:59:33 +0100
committerThibaut Girka <thib@sitedethib.com>2019-03-16 20:59:33 +0100
commit4aa6aba6ee95ba37df7ca1d9c65f360b1b00ec04 (patch)
tree7c90513d2576dba9d71ac069ca28ac7e4db72a28 /app/workers
parent6af2300454c960ef83f7b7d31e9b829e0d5a8e38 (diff)
parent735b8be2042a29fb10077aaab526832b95a041a9 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- app/services/remove_status_service.rb
  Conflict because we still handle the direct timeline.
  Took upstream changes, with that one extra function call.
- config/locales/ca.yml
  Conflict because theme names were updated.
  Decided to *keep* the theme names even if they are useless
  to avoid future conflicts.
- config/locales/oc.yml
  Decided to *keep* the theme names even if they are useless
  to avoid future conflicts.
- config/locales/pl.yml
  Decided to *keep* the theme names even if they are useless
  to avoid future conflicts.
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/distribution_worker.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/workers/distribution_worker.rb b/app/workers/distribution_worker.rb
index f423d43ae..4e20ef31b 100644
--- a/app/workers/distribution_worker.rb
+++ b/app/workers/distribution_worker.rb
@@ -4,7 +4,13 @@ class DistributionWorker
   include Sidekiq::Worker
 
   def perform(status_id)
-    FanOutOnWriteService.new.call(Status.find(status_id))
+    RedisLock.acquire(redis: Redis.current, key: "distribute:#{status_id}") do |lock|
+      if lock.acquired?
+        FanOutOnWriteService.new.call(Status.find(status_id))
+      else
+        raise Mastodon::RaceConditionError
+      end
+    end
   rescue ActiveRecord::RecordNotFound
     true
   end