summaryrefslogtreecommitdiff
path: root/addons/document/std_index.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/document/std_index.py')
-rw-r--r--addons/document/std_index.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/addons/document/std_index.py b/addons/document/std_index.py
index 2a588a017c1..7cfcd36e2dc 100644
--- a/addons/document/std_index.py
+++ b/addons/document/std_index.py
@@ -96,8 +96,13 @@ class DocIndex(indexer):
def _doIndexFile(self,fname):
fp = Popen(['antiword', fname], shell=False, stdout=PIPE).stdout
- return _to_unicode(fp.read())
-
+ try:
+ file_data = _to_unicode(fp.read())
+ finally:
+ fp.close()
+
+ return file_data
+
cntIndex.register(DocIndex())
class DocxIndex(indexer):
@@ -158,7 +163,12 @@ class PdfIndex(indexer):
def _doIndexFile(self,fname):
fp = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE).stdout
- return _to_unicode( fp.read())
+ try:
+ file_data = _to_unicode( fp.read())
+ finally:
+ fp.close()
+
+ return file_data
cntIndex.register(PdfIndex())