Don't allow _upsert_files failure to cancel entire refresh.

This commit is contained in:
Roland 2023-07-14 17:03:32 -06:00
parent 478f380b0c
commit 29c352b423
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93

View file

@ -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 = ''