mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Using refresh logger in refreshing functions. Not setting ebook.title. Logging traceback when failing to index ebook.
This commit is contained in:
parent
550377580b
commit
aa5eedc7d6
2 changed files with 5 additions and 6 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue