Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ensuring that temp directories are cleaned up on gm or tesseract exce…

…ption.
  • Loading branch information...
commit 18363f9577497e5526d14e1103a21057ab7649df 1 parent e85000a
Jeremy Ashkenas jashkenas authored
1  lib/docsplit/image_extractor.rb
View
@@ -46,6 +46,7 @@ def convert(pdf, size, format, previous=nil)
raise ExtractionFailed, result if $? != 0
end
end
+ ensure
FileUtils.remove_entry_secure tempdir if File.exists?(tempdir)
end
1  lib/docsplit/text_extractor.rb
View
@@ -71,6 +71,7 @@ def extract_from_ocr(pdf, pages)
run "MAGICK_TMPDIR=#{tempdir} OMP_NUM_THREADS=2 gm convert #{MEMORY_ARGS} #{OCR_FLAGS} #{pdf} #{tiff} 2>&1"
run "tesseract #{tiff} #{base_path} -l eng 2>&1"
end
+ ensure
FileUtils.remove_entry_secure tempdir if File.exists?(tempdir)
end
Please sign in to comment.
Something went wrong with that request. Please try again.