about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-03-20 20:02:58 +0100
committerGitHub <noreply@github.com>2023-03-20 20:02:58 +0100
commitbdeb6ff18049870e76139f7434249096bc4d1fca (patch)
treeda317fcb6cfda16ae9b77bd3a72ddde875738b2f /lib
parent0ca54a4105907fc61792052fcdb703af8bbd1fee (diff)
Fix crash in `tootctl` commands making use of parallelization when Elasticsearch is enabled (#24182)
Diffstat (limited to 'lib')
-rw-r--r--lib/mastodon/cli_helper.rb16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/mastodon/cli_helper.rb b/lib/mastodon/cli_helper.rb
index 8704edd75..ab1351ae8 100644
--- a/lib/mastodon/cli_helper.rb
+++ b/lib/mastodon/cli_helper.rb
@@ -52,14 +52,16 @@ module Mastodon
 
             progress.log("Processing #{item.id}") if options[:verbose]
 
-            result = ActiveRecord::Base.connection_pool.with_connection do
-              yield(item)
-            ensure
-              RedisConfiguration.pool.checkin if Thread.current[:redis]
-              Thread.current[:redis] = nil
+            Chewy.strategy(:mastodon) do
+              result = ActiveRecord::Base.connection_pool.with_connection do
+                yield(item)
+              ensure
+                RedisConfiguration.pool.checkin if Thread.current[:redis]
+                Thread.current[:redis] = nil
+              end
+
+              aggregate.increment(result) if result.is_a?(Integer)
             end
-
-            aggregate.increment(result) if result.is_a?(Integer)
           rescue => e
             progress.log pastel.red("Error processing #{item.id}: #{e}")
           ensure