MicheleCotrufo/pdf2doi

File not closed

DuzaBF opened this issue · 1 comments

Hi,

The function pdf2doi_singlefile does not close the opened pdf file. The close file statement is not executed due to return statements on successful identifier finding.

pdf2doi/pdf2doi/main.py

Lines 161 to 165 in d8e7117

if result['identifier']:
return result
if flag_closefile:
file.close()

This causes the issue with pdf-rename on Windows. The renaming attempt results in access error as file is opened by the script itself.

I'll make PR shortly to fix this.

I merged the contribution from DuzaBF, and made some additional changes to the code to make sure that a result dictionary with the key 'identifier' is always returned. This should fix this bug.
Please download the version 1.3 of pdf2doi :) I will also add the requirement in the requirements.txt of pdfrenamer