Using refresh logger in refreshing functions. Not setting ebook.title. Logging traceback when failing to index ebook.

This commit is contained in:
Roland 2023-03-26 09:50:42 -06:00
parent 550377580b
commit aa5eedc7d6
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 5 additions and 6 deletions

View file

@ -213,14 +213,14 @@ def _model_ebook(ebook: EBook) -> EBook:
size = ebook_file.stat().st_size
# Only index if it hasn't been done, or if the file has changed.
changed = size != ebook.size or not ebook.title
changed = size != ebook.size or not ebook.file_group.title
if epub_file and changed:
# Only read the contents of the file if it has changed.
try:
data = extract_ebook_data(ebook_file, ebook_mimetype)
if data:
# Title is a_text.
ebook.file_group.title = ebook.file_group.a_text = ebook.title = data.title
ebook.file_group.title = ebook.file_group.a_text = data.title
# Creator is b_text.
ebook.file_group.b_text = ebook.creator = data.creator
# All text is d_text.
@ -282,7 +282,7 @@ async def ebook_modeler():
file_group.model = EBook.__tablename__
file_group.indexed = True
except Exception as e:
logger.error(f'Failed to index ebook {file_group}')
logger.error(f'Failed to index ebook {file_group}', exc_info=e)
if PYTEST:
raise

View file

@ -336,8 +336,7 @@ def _upsert_files(files: List[pathlib.Path], idempotency: datetime.datetime):
curs.execute(stmt)
need_index = [i[0] for i in curs.fetchall() if i[1] is False]
if need_index:
logger.info(f'Invalidated indexes of {len(need_index)} file groups')
logger.debug(f'Invalidated indexes of file groups {need_index}')
refresh_logger.info(f'Invalidated indexes of {len(need_index)} file groups')
async def refresh_discover_paths(paths: List[pathlib.Path], idempotency: datetime.datetime = None):
@ -398,7 +397,7 @@ async def refresh_discover_paths(paths: List[pathlib.Path], idempotency: datetim
-- Delete any files in the refreshed paths that were not updated.
{" OR " + wheres if deleted_files else wheres}
'''
logger.debug(stmt)
refresh_logger.debug(stmt)
curs.execute(stmt)