diff --git a/lib/labimotion/libs/converter.rb b/lib/labimotion/libs/converter.rb index e13b883..bce44c2 100644 --- a/lib/labimotion/libs/converter.rb +++ b/lib/labimotion/libs/converter.rb @@ -125,7 +125,7 @@ def self.handle_response(oat, response, current_user = {}) # rubocop: disable Me tmp_file.rewind filename = oat.filename - name = "#{File.basename(filename, '.*')}.zip" + name = "#{File.basename(filename, '.*')}#{File.extname(filename) == '.zip' ? '.bagit.zip' : '.zip'}" att = Attachment.new( filename: name, file_path: tmp_file.path, diff --git a/lib/labimotion/libs/nmr_mapper.rb b/lib/labimotion/libs/nmr_mapper.rb index 7280dff..49112ef 100644 --- a/lib/labimotion/libs/nmr_mapper.rb +++ b/lib/labimotion/libs/nmr_mapper.rb @@ -34,7 +34,7 @@ def process_ds(id, current_user = {}) return Labimotion::ConState::NONE if att.nil? result = process(att) - return Labimotion::ConState::NONE if result.nil? + return Labimotion::ConState::WAIT if result.nil? handle_process_result(result, att, id, current_user) end @@ -136,7 +136,7 @@ def handle_process_result(result, att, id, current_user) if result[:is_bagit] handle_bagit_result(att, id, current_user) elsif invalid_metadata?(result) - Labimotion::ConState::NONE + Labimotion::ConState::WAIT else handle_nmr_result(result, att, current_user) end diff --git a/lib/labimotion/models/concerns/attachment_converter.rb b/lib/labimotion/models/concerns/attachment_converter.rb index f257c9b..1584717 100644 --- a/lib/labimotion/models/concerns/attachment_converter.rb +++ b/lib/labimotion/models/concerns/attachment_converter.rb @@ -31,6 +31,7 @@ def exec_converter case con_state when Labimotion::ConState::NMR self.con_state = Labimotion::NmrMapper.process_ds(id, current_user) + return exec_converter if con_state == Labimotion::ConState::WAIT update_column(:con_state, con_state) when Labimotion::ConState::WAIT self.con_state = Labimotion::Converter.jcamp_converter(id, current_user)