Skip to content

Commit

Permalink
Fixed error message for previews for Active Storage 7.1.4 - fixes #200
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Barrow <dev@scottbarrow.ca>
  • Loading branch information
ankane and scottbarrow committed Sep 8, 2024
1 parent 81a812e commit 789ad49
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.4.1 (unreleased)

- Fixed error message for previews for Active Storage 7.1.4

## 1.4.0 (2024-08-09)

- Added support for Active Record 7.2
Expand Down
13 changes: 13 additions & 0 deletions lib/lockbox/active_storage_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ def preview(*args)
super
end

if ActiveStorage::VERSION::STRING.to_f == 7.1 && ActiveStorage.version >= "7.1.4"
def transform_variants_later
blob.instance_variable_set(:@lockbox_encrypted, true) if Utils.encrypted_options(record, name)
super
end
end

if ActiveStorage::VERSION::MAJOR >= 6
def open(**options)
blob.open(**options) do |file|
Expand All @@ -150,6 +157,12 @@ def open(**options)
end

module Blob
if ActiveStorage::VERSION::STRING.to_f == 7.1 && ActiveStorage.version >= "7.1.4"
def preview_image_needed_before_processing_variants?
!instance_variable_defined?(:@lockbox_encrypted) && super
end
end

private

def extract_content_type(io)
Expand Down

0 comments on commit 789ad49

Please sign in to comment.