about summary refs log tree commit diff
path: root/lib/mastodon/cli_helper.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-02-19 10:42:55 +0100
committerClaire <claire.github-309c@sitedethib.com>2023-02-19 10:42:55 +0100
commit7452a959989f1259b68d08814437bab53ee89bb0 (patch)
tree389c2be7b7a326729e4687019a58950a07bd2dde /lib/mastodon/cli_helper.rb
parent4c68189d2b8b6a9a74fc13862b11bf6c6d523409 (diff)
parentfef6c59b3abe349132dbe910b6aa243e59b732bb (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `.github/dependabot.yml`:
  Upstream made changes while we have dropped this file.
  Keep the file deleted.
- `.prettierignore`:
  Upstream made changes at the end of the file, where we
  had our extra lines.
  Just moved our extra lines back at the end.
- `app/serializers/initial_state_serializer.rb`:
  Upstream code style changes.
  Applied them.
- `app/services/backup_service.rb`:
  Upstream code style changes.
  Applied them.
Diffstat (limited to 'lib/mastodon/cli_helper.rb')
-rw-r--r--lib/mastodon/cli_helper.rb42
1 files changed, 20 insertions, 22 deletions
diff --git a/lib/mastodon/cli_helper.rb b/lib/mastodon/cli_helper.rb
index a78a28e27..8704edd75 100644
--- a/lib/mastodon/cli_helper.rb
+++ b/lib/mastodon/cli_helper.rb
@@ -42,30 +42,28 @@ module Mastodon
 
         items.each do |item|
           futures << Concurrent::Future.execute(executor: pool) do
-            begin
-              if !progress.total.nil? && progress.progress + 1 > progress.total
-                # The number of items has changed between start and now,
-                # since there is no good way to predict the final count from
-                # here, just change the progress bar to an indeterminate one
-
-                progress.total = nil
-              end
-
-              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
-              end
-
-              aggregate.increment(result) if result.is_a?(Integer)
-            rescue => e
-              progress.log pastel.red("Error processing #{item.id}: #{e}")
+            if !progress.total.nil? && progress.progress + 1 > progress.total
+              # The number of items has changed between start and now,
+              # since there is no good way to predict the final count from
+              # here, just change the progress bar to an indeterminate one
+
+              progress.total = nil
+            end
+
+            progress.log("Processing #{item.id}") if options[:verbose]
+
+            result = ActiveRecord::Base.connection_pool.with_connection do
+              yield(item)
             ensure
-              progress.increment
+              RedisConfiguration.pool.checkin if Thread.current[:redis]
+              Thread.current[:redis] = nil
             end
+
+            aggregate.increment(result) if result.is_a?(Integer)
+          rescue => e
+            progress.log pastel.red("Error processing #{item.id}: #{e}")
+          ensure
+            progress.increment
           end
         end