Defer deletion of avatars to a background job
authorTom Hughes <tom@compton.nu>
Tue, 16 Jul 2019 07:27:14 +0000 (08:27 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 16 Jul 2019 07:27:14 +0000 (08:27 +0100)
app/controllers/users_controller.rb
app/models/user.rb

index 8c23400..9c918fe 100644 (file)
@@ -665,10 +665,10 @@ class UsersController < ApplicationController
       user.avatar.attach(params[:user][:avatar])
       user.image_use_gravatar = false
     when "delete" then
-      user.avatar.purge
+      user.avatar.purge_later
       user.image_use_gravatar = false
     when "gravatar" then
-      user.avatar.purge
+      user.avatar.purge_later
       user.image_use_gravatar = true
     end
 
index 13248e4..8e3ac17 100644 (file)
@@ -269,7 +269,7 @@ class User < ActiveRecord::Base
   ##
   # delete a user - leave the account but purge most personal data
   def delete
-    avatar.purge
+    avatar.purge_later
 
     self.display_name = "user_#{id}"
     self.description = ""