From 98e6ba2b502e86081e2b7cdacdb4c7d8e5dca779 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 23 Jun 2016 20:56:36 -0400 Subject: [PATCH] Cleanup temporary files after running the poppler parser. GitLab issue #309. Thanks to @miek770 for finding the issue and solution. --- mayan/apps/ocr/parsers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mayan/apps/ocr/parsers.py b/mayan/apps/ocr/parsers.py index 4a47422d21..16f8539abd 100644 --- a/mayan/apps/ocr/parsers.py +++ b/mayan/apps/ocr/parsers.py @@ -12,7 +12,7 @@ import subprocess from django.utils.translation import ugettext_lazy as _ from common.settings import setting_temporary_directory -from common.utils import copyfile, mkstemp +from common.utils import copyfile, fs_cleanup, mkstemp from .exceptions import ParserError, NoMIMETypeMatch from .models import DocumentPageContent @@ -155,10 +155,12 @@ class PopplerParser(Parser): return_code = proc.wait() if return_code != 0: logger.error(proc.stderr.readline()) + fs_cleanup(temp_filepath) raise ParserError output = proc.stdout.read() + fs_cleanup(temp_filepath) if output == b'\x0c': logger.debug('Parser didn\'t return any output')