Dont Convert when initialized by import

This commit is contained in:
Thorsten Claus 2022-07-15 11:24:02 +02:00 committed by Benjamin Neff
parent 492ac74819
commit f995e6af0d
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
3 changed files with 3 additions and 2 deletions

View file

@ -38,6 +38,7 @@ class Photo < ApplicationRecord
mount_uploader :processed_image, ProcessedImage
mount_uploader :unprocessed_image, UnprocessedImage
attr_accessor :keep_original_format
belongs_to :status_message, foreign_key: :status_message_guid, primary_key: :guid, optional: true
validates_associated :status_message
@ -50,7 +51,6 @@ class Photo < ApplicationRecord
after_commit on: :create do
queue_processing_job if author.local?
end
scope :on_statuses, ->(post_guids) {

View file

@ -74,6 +74,7 @@ class ImportService
def store_and_process_photo(photo, uploaded_file, random_string)
File.open(uploaded_file) do |file|
photo.random_string = random_string
photo.keep_original_format = true
photo.unprocessed_image.store! file
photo.update_remote_path
photo.save(touch: false)

View file

@ -31,7 +31,7 @@ class UnprocessedImage < CarrierWave::Uploader::Base
def needs_converting?
extname = File.extname(@filename)
%w[.webp .gif].exclude?(extname)
%w[.webp .gif].exclude?(extname) && !model.keep_original_format
end
process :basic_process