lib/libis/format/tool/pdf_copy.rb in libis-format-0.9.49 vs lib/libis/format/tool/pdf_copy.rb in libis-format-0.9.50

- old
+ new

@@ -21,17 +21,23 @@ if OS.java? # TODO: import library and execute in current VM. For now do exactly as in MRI. end - Libis::Tools::Command.run( + timeout = Libis::Format::Config[:timeouts][:pdf_copy] + result = Libis::Tools::Command.run( Libis::Format::Config[:java_path], '-cp', Libis::Format::Config[:pdf_tool], 'CopyPdf', '--file_input', source, '--file_output', target, - *options + *options, + timeout: timeout, + kill_after: timeout * 2 ) + + raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout] + raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty? end end end