Only getting PDF title's once.

This commit is contained in:
Roland 2022-12-19 13:00:15 -07:00
parent 58a4dfa335
commit 3881d0fd9d
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 8 additions and 1 deletions

View file

@ -29,7 +29,8 @@ def model_pdf(groups: Dict[str, List[File]], _: Session):
logger.warning(f'Cannot get title from PDF without PyPDF2')
return
pdf_files = (file for group in groups.values() for file in group if file.mimetype == 'application/pdf')
pdf_files = (file for group in groups.values() for file in group if
file.indexed is not True and file.mimetype == 'application/pdf')
for file in pdf_files:
path: pathlib.Path = file.path.path if hasattr(file.path, 'path') else file.path

View file

@ -1,3 +1,5 @@
from unittest import mock
import pytest
from wrolpi.files.lib import refresh_files
@ -9,5 +11,9 @@ async def test_pdf_title(test_session, example_pdf):
"""PDF modeler extracts the PDF's title."""
await refresh_files()
with mock.patch('wrolpi.files.pdfs.get_pdf_title') as mock_get_pdf_title:
mock_get_pdf_title.side_effect = Exception('should not be read again')
await refresh_files()
pdf: File = test_session.query(File).one()
assert pdf.title == 'WROLPi Test PDF'