From 29c352b4238f1b1efee18fcf2f2c59980734a98e Mon Sep 17 00:00:00 2001 From: Roland Date: Fri, 14 Jul 2023 17:03:32 -0600 Subject: [PATCH] Don't allow _upsert_files failure to cancel entire refresh. --- wrolpi/files/lib.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wrolpi/files/lib.py b/wrolpi/files/lib.py index 854ded3a..fa26be3b 100644 --- a/wrolpi/files/lib.py +++ b/wrolpi/files/lib.py @@ -446,13 +446,19 @@ async def refresh_discover_paths(paths: List[pathlib.Path], idempotency: datetim files.extend(new_files) if len(files) >= 100: # Wait until there are enough files to perform the upsert. - _upsert_files(files, idempotency) + try: + _upsert_files(files, idempotency) + except Exception as e: + logger.error(f'Failed to upsert files', exc_info=e) files = list() # Sleep to catch cancel. await asyncio.sleep(0) if files: # Not enough files for the chunks above, finish what is left. - _upsert_files(files, idempotency) + try: + _upsert_files(files, idempotency) + except Exception as e: + logger.error(f'Failed to upsert files', exc_info=e) with get_db_curs(commit=True) as curs: wheres = ''