When streaming (= a block is passed to download) it only downloads a chunk for the file here and returns nil to the caller:
|
def download |
|
result = super |
This leads to the following error when doing something like ActiveStorage::Attachment.last.download { |chunk| }
TypeError (can't convert NilClass to String):
/gems/lockbox-2.0.1/lib/lockbox/encryptor.rb:72:in 'Lockbox::Encryptor#check_string'
/gems/lockbox-2.0.1/lib/lockbox/encryptor.rb:24:in 'Lockbox::Encryptor#decrypt'
/gems/lockbox-2.0.1/lib/lockbox/utils.rb:113:in 'block in Lockbox::Utils.decrypt_result'
/gems/lockbox-2.0.1/lib/lockbox/utils.rb:112:in 'Lockbox::Utils.decrypt_result'
/gems/lockbox-2.0.1/lib/lockbox/active_storage_extensions.rb:91:in 'Lockbox::ActiveStorageExtensions::Attachment#download'
In addition the block receives the first chunk of encrypted data first (before the exception is raised) which I think is not expected, too.
I think it should raise like it does below, for example do this:
def download
raise Lockbox::Error, "Streaming not supported for encrypted files" if block_given?
result = super
Edit: I guess it should raise for download_chunk, too?
Wdyt?
When streaming (= a block is passed to download) it only downloads a chunk for the file here and returns
nilto the caller:lockbox/lib/lockbox/active_storage_extensions.rb
Lines 82 to 83 in ef24e9d
This leads to the following error when doing something like
ActiveStorage::Attachment.last.download { |chunk| }In addition the block receives the first chunk of encrypted data first (before the exception is raised) which I think is not expected, too.
I think it should raise like it does below, for example do this:
Edit: I guess it should raise for download_chunk, too?
Wdyt?