]> cat aescling's git repositories - mastodon.git/commitdiff
Fix inconsistency in error handling when removing a status (#17974)
authorClaire <claire.github-309c@sitedethib.com>
Wed, 6 Apr 2022 18:57:52 +0000 (20:57 +0200)
committerGitHub <noreply@github.com>
Wed, 6 Apr 2022 18:57:52 +0000 (20:57 +0200)
Not completely sure this could actually have any ill effect, but if
`RemoveStatusService` fails to acquire a lock in an
`ActivityPub::ProcessingWorker` job processing a `Delete`, the status
is currently discarded and causes a job failure but the next time the
job is attempted, it will skip deleting the status due to it being
discarded.

This commit makes the behavior of `RemoveStatusService` a bit more consistent
in case of failure to acquire the lock.

app/services/remove_status_service.rb

index 159aec1f23d5d613b4f7b2123bcca9b059dd3990..41730154dcac1ed7b42b20c6d0290ba02a457e44 100644 (file)
@@ -17,10 +17,10 @@ class RemoveStatusService < BaseService
     @account  = status.account
     @options  = options
 
-    @status.discard
-
     RedisLock.acquire(lock_options) do |lock|
       if lock.acquired?
+        @status.discard
+
         remove_from_self if @account.local?
         remove_from_followers
         remove_from_lists