Cleanup temporary files after running the poppler parser. GitLab issue #309. Thanks to @miek770 for finding the issue and solution.
This commit is contained in:
@@ -12,7 +12,7 @@ import subprocess
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from common.settings import setting_temporary_directory
|
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 .exceptions import ParserError, NoMIMETypeMatch
|
||||||
from .models import DocumentPageContent
|
from .models import DocumentPageContent
|
||||||
@@ -155,10 +155,12 @@ class PopplerParser(Parser):
|
|||||||
return_code = proc.wait()
|
return_code = proc.wait()
|
||||||
if return_code != 0:
|
if return_code != 0:
|
||||||
logger.error(proc.stderr.readline())
|
logger.error(proc.stderr.readline())
|
||||||
|
fs_cleanup(temp_filepath)
|
||||||
|
|
||||||
raise ParserError
|
raise ParserError
|
||||||
|
|
||||||
output = proc.stdout.read()
|
output = proc.stdout.read()
|
||||||
|
fs_cleanup(temp_filepath)
|
||||||
|
|
||||||
if output == b'\x0c':
|
if output == b'\x0c':
|
||||||
logger.debug('Parser didn\'t return any output')
|
logger.debug('Parser didn\'t return any output')
|
||||||
|
|||||||
Reference in New Issue
Block a user