Skip to content
Extraits de code Groupes Projets
Valider 4f337c02 rédigé par unarist's avatar unarist Validation de GitHub
Parcourir les fichiers

Fix Cocaine::ExitStatusError when upload small non-animated GIF (#5489)

Looks like copied tempfile need to be flushed before further processing. This issue won't happen if the uploaded file has enough file size.
parent 02f7f361
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -10,6 +10,7 @@ module Paperclip ...@@ -10,6 +10,7 @@ module Paperclip
unless options[:style] == :original && num_frames > 1 unless options[:style] == :original && num_frames > 1
tmp_file = Paperclip::TempfileFactory.new.generate(attachment.instance.file_file_name) tmp_file = Paperclip::TempfileFactory.new.generate(attachment.instance.file_file_name)
tmp_file << file.read tmp_file << file.read
tmp_file.flush
return tmp_file return tmp_file
end end
......
spec/fixtures/files/mini-static.gif

1,16 ko

...@@ -20,20 +20,29 @@ RSpec.describe MediaAttachment, type: :model do ...@@ -20,20 +20,29 @@ RSpec.describe MediaAttachment, type: :model do
end end
describe 'non-animated gif non-conversion' do describe 'non-animated gif non-conversion' do
let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture('attachment.gif')) } fixtures = [
{ filename: 'attachment.gif', width: 600, height: 400, aspect: 1.5 },
{ filename: 'mini-static.gif', width: 32, height: 32, aspect: 1.0 },
]
it 'sets type to image' do fixtures.each do |fixture|
expect(media.type).to eq 'image' context fixture[:filename] do
end let(:media) { MediaAttachment.create(account: Fabricate(:account), file: attachment_fixture(fixture[:filename])) }
it 'leaves original file as-is' do it 'sets type to image' do
expect(media.file_content_type).to eq 'image/gif' expect(media.type).to eq 'image'
end end
it 'sets meta' do it 'leaves original file as-is' do
expect(media.file.meta["original"]["width"]).to eq 600 expect(media.file_content_type).to eq 'image/gif'
expect(media.file.meta["original"]["height"]).to eq 400 end
expect(media.file.meta["original"]["aspect"]).to eq 1.5
it 'sets meta' do
expect(media.file.meta["original"]["width"]).to eq fixture[:width]
expect(media.file.meta["original"]["height"]).to eq fixture[:height]
expect(media.file.meta["original"]["aspect"]).to eq fixture[:aspect]
end
end
end end
end end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter