From de6b58536888d2cee42a0e9874022b22131817f1 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 23 Oct 2018 12:20:21 +1100 Subject: [PATCH] minor, bypass gravatar update if user does not match this protects against a race condition that can happen when a user record is destroyed reasonably quickly --- app/jobs/regular/update_gravatar.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/regular/update_gravatar.rb b/app/jobs/regular/update_gravatar.rb index bbff6a6b226..53d4f61a4f4 100644 --- a/app/jobs/regular/update_gravatar.rb +++ b/app/jobs/regular/update_gravatar.rb @@ -8,7 +8,7 @@ module Jobs user = User.find_by(id: args[:user_id]) avatar = UserAvatar.find_by(id: args[:avatar_id]) - if user && avatar + if user && avatar && avatar.user&.id == user.id avatar.update_gravatar! if !user.uploaded_avatar_id && avatar.gravatar_upload_id user.update_column(:uploaded_avatar_id, avatar.gravatar_upload_id)