Skip to content

Commit

Permalink
Add patch to ActiveStorage::Blob#delete
Browse files Browse the repository at this point in the history
Prevent deletion of variants. We don't currently use variants and this
causes timeouts (when doing a remote globs to find variant files to be
deleted) when using a ActiveStorage SFTP service.

See: https://github.com/rails/rails/blob/6-1-stable/activestorage/app/models/active_storage/blob.rb#L287-L290
  • Loading branch information
gbp committed Mar 24, 2022
1 parent 0b73b61 commit 57608d9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/model_patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,14 @@ def disable

prepend DisableWithProtection
end

ActiveStorage::Blob.class_eval do
def delete
service.delete(key)
# Prevent deletion of variants. We don't currently use variants and this
# causes timeouts (when doing a remote globs to find variant files to be
# deleted) when using a ActiveStorage SFTP service
# service.delete_prefixed("variants/#{key}/") if image?
end
end
end

0 comments on commit 57608d9

Please sign in to comment.