Fixes issue ##2504 - Login into Zammad not possible, application server puma
will raise 100% or more cpu.
This commit is contained in:
parent
909f4b7eaf
commit
cdb4042961
1 changed files with 20 additions and 10 deletions
|
@ -281,6 +281,10 @@ returns
|
|||
file.provider
|
||||
end
|
||||
|
||||
def self.semaphore
|
||||
@semaphore ||= Mutex.new
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def image_resize(content, width)
|
||||
|
@ -295,6 +299,9 @@ returns
|
|||
temp_file.binmode
|
||||
temp_file.write(content)
|
||||
temp_file.close
|
||||
|
||||
temp_file_resize = nil
|
||||
self.class.semaphore.synchronize do
|
||||
image = Rszr::Image.load(temp_file.path)
|
||||
|
||||
# do not resize image if image is smaller or already same size
|
||||
|
@ -308,6 +315,9 @@ returns
|
|||
image.resize!(width, :auto)
|
||||
temp_file_resize = ::Tempfile.new.path
|
||||
image.save(temp_file_resize)
|
||||
image.send(:handle).finalize!
|
||||
end
|
||||
|
||||
image_resized = ::File.binread(temp_file_resize)
|
||||
|
||||
Cache.write(cache_key, image_resized, { expires_in: 6.months })
|
||||
|
|
Loading…
Reference in a new issue