mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +08:00
Fix file post process method
This commit is contained in:
parent
18b31875bb
commit
d5f9604e1c
2 changed files with 12 additions and 12 deletions
|
@ -147,25 +147,20 @@ class StepsController < ApplicationController
|
|||
destroy_attributes(step_params_all)
|
||||
|
||||
# Attach newly uploaded files, and than remove their blob ids from the parameters
|
||||
new_assets = []
|
||||
step_params_all[:assets_attributes]&.each do |key, value|
|
||||
next unless value[:signed_blob_id]
|
||||
|
||||
@step.assets
|
||||
.create!(created_by: current_user, last_modified_by: current_user, team: current_team)
|
||||
.file
|
||||
.attach(value[:signed_blob_id])
|
||||
new_asset = @step.assets.create!(created_by: current_user, last_modified_by: current_user, team: current_team)
|
||||
new_asset.file
|
||||
.attach(value[:signed_blob_id])
|
||||
new_assets.push(new_asset.id)
|
||||
step_params_all[:assets_attributes].delete(key)
|
||||
end
|
||||
|
||||
@step.assign_attributes(step_params_all)
|
||||
@step.last_modified_by = current_user
|
||||
|
||||
@step.assets.each do |asset|
|
||||
asset.created_by = current_user if asset.new_record?
|
||||
asset.last_modified_by = current_user unless asset.new_record?
|
||||
asset.team = current_team
|
||||
end
|
||||
|
||||
@step.tables.each do |table|
|
||||
table.created_by = current_user if table.new_record?
|
||||
table.last_modified_by = current_user unless table.new_record?
|
||||
|
@ -189,7 +184,7 @@ class StepsController < ApplicationController
|
|||
|
||||
# Post process step assets
|
||||
@step.assets.each do |asset|
|
||||
asset.post_process_file(team) if asset.changed?
|
||||
asset.post_process_file(team) if new_assets.include? asset.id
|
||||
end
|
||||
|
||||
# Generate activity
|
||||
|
|
|
@ -251,7 +251,12 @@ 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?
|
||||
begin
|
||||
yomu_server_pid = Yomu.class_variable_get(:@@server_pid)
|
||||
rescue StandardError
|
||||
yomu_server_pid = nil
|
||||
end
|
||||
Yomu.server(:text) if !ENV['NO_TIKA_SERVER'] && yomu_server_pid
|
||||
blob.open do |tmp_file|
|
||||
text_data = Yomu.new(tmp_file.path).text
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue