Pass an array through our stack, don't bother converting back & forth

Users aren't likely to pass non-array values here anyway.
This commit is contained in:
Kasper Timm Hansen 2021-12-04 02:25:42 +01:00
parent f34fcac88f
commit 1df9b01fe6
7 changed files with 9 additions and 9 deletions

View File

@ -154,7 +154,7 @@ class ActiveStorage::Blob < ActiveStorage::Record
content_type ||= blobs.pluck(:content_type).compact.first
new(filename: filename, content_type: content_type, metadata: metadata, byte_size: blobs.sum(&:byte_size)).tap do |combined_blob|
combined_blob.compose(*blobs.pluck(:key))
combined_blob.compose(blobs.pluck(:key))
combined_blob.save!
end
end
@ -268,9 +268,9 @@ class ActiveStorage::Blob < ActiveStorage::Record
service.upload key, io, checksum: checksum, **service_metadata
end
def compose(*keys) # :nodoc:
def compose(keys) # :nodoc:
self.composed = true
service.compose(*keys, key, **service_metadata)
service.compose(keys, key, **service_metadata)
end
# Downloads the file associated with this blob. If no block is given, the entire file is read into memory and returned.

View File

@ -91,7 +91,7 @@ module ActiveStorage
end
# Concatenate multiple files into a single "composed" file.
def compose(*source_keys, destination_key, filename: nil, content_type: nil, disposition: nil, custom_metadata: {})
def compose(source_keys, destination_key, filename: nil, content_type: nil, disposition: nil, custom_metadata: {})
raise NotImplementedError
end

View File

@ -107,7 +107,7 @@ module ActiveStorage
{ "Content-Type" => content_type, "Content-MD5" => checksum, "x-ms-blob-content-disposition" => content_disposition, "x-ms-blob-type" => "BlockBlob", **custom_metadata_headers(custom_metadata) }
end
def compose(*source_keys, destination_key, filename: nil, content_type: nil, disposition: nil, custom_metadata: {})
def compose(source_keys, destination_key, filename: nil, content_type: nil, disposition: nil, custom_metadata: {})
content_disposition = content_disposition_with(type: disposition, filename: filename) if disposition && filename
client.create_append_blob(

View File

@ -100,7 +100,7 @@ module ActiveStorage
File.join root, folder_for(key), key
end
def compose(*source_keys, destination_key, **)
def compose(source_keys, destination_key, **)
File.open(make_path_for(destination_key), "w") do |destination_file|
source_keys.each do |source_key|
File.open(path_for(source_key), "rb") do |source_file|

View File

@ -134,7 +134,7 @@ module ActiveStorage
headers
end
def compose(*source_keys, destination_key, filename: nil, content_type: nil, disposition: nil, custom_metadata: {})
def compose(source_keys, destination_key, filename: nil, content_type: nil, disposition: nil, custom_metadata: {})
bucket.compose(source_keys, destination_key).update do |file|
file.content_type = content_type
file.content_disposition = content_disposition_with(type: disposition, filename: filename) if disposition && filename

View File

@ -95,7 +95,7 @@ module ActiveStorage
{ "Content-Type" => content_type, "Content-MD5" => checksum, "Content-Disposition" => content_disposition, **custom_metadata_headers(custom_metadata) }
end
def compose(*source_keys, destination_key, filename: nil, content_type: nil, disposition: nil, custom_metadata: {})
def compose(source_keys, destination_key, filename: nil, content_type: nil, disposition: nil, custom_metadata: {})
content_disposition = content_disposition_with(type: disposition, filename: filename) if disposition && filename
object_for(destination_key).upload_stream(

View File

@ -153,7 +153,7 @@ module ActiveStorage::Service::SharedServiceTests
)
end
destination_key = SecureRandom.base58(24)
@service.compose(*keys, destination_key)
@service.compose(keys, destination_key)
assert_equal "Together", @service.download(destination_key)
end