diff --git a/app/models/asset.rb b/app/models/asset.rb index 432c4a2ce..a20c434a2 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -296,9 +296,13 @@ class Asset < ApplicationRecord text_data = mjs_doc.search("//Field[@name='text']").collect(&:text).join(' ') else # Start Tika as a server - Yomu.server(:text) if !ENV['NO_TIKA_SERVER'] && Yomu.class_variable_get(:@@server_pid).nil? - blob.open do |tmp_file| - text_data = Yomu.new(tmp_file.path).text + Yomu.server(:text) + begin + blob.open do |tmp_file| + text_data = Yomu.new(tmp_file.path).text + end + ensure + Yomu.kill_server! end end