[ocrfeeder] Add a prefix to the symlink when importing a PDF



commit 72a60178e579f13c26ddd90030713658ddbc0472
Author: Joaquim Rocha <me joaquimrocha com>
Date:   Sun Mar 8 21:47:56 2020 +0100

    Add a prefix to the symlink when importing a PDF
    
    This is just an extra safety measure (maybe over-careful) to reduce
    the chances of future code modifications removing the original PDF
    path.

 src/ocrfeeder/util/lib.py | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/src/ocrfeeder/util/lib.py b/src/ocrfeeder/util/lib.py
index 71a2965..8f5016b 100644
--- a/src/ocrfeeder/util/lib.py
+++ b/src/ocrfeeder/util/lib.py
@@ -75,6 +75,9 @@ def convertPdfToImages(pdf_file, temp_dir = '/tmp'):
     if pdf_file != pdf_file_safe:
         try:
             pdf_path_safe = os.path.join(dir_name, file_name_safe)
+            # The prefix added here is for extra safety so there are less chances
+            # for this path to match the original one in future changes.
+            pdf_path_safe = os.path.join(dir_name, 'OCRFEEDER_' + file_name_safe)
             os.symlink(pdf_file, pdf_path_safe)
         except:
             debug('Unable to convert PDF: Cannot create temp symlink in: %s', dir_name)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]