refresh_links_for_backend: gracefully handle project-less files.

This commit is contained in:
Sybren A. Stüvel 2016-07-27 10:50:40 +02:00
parent ece498a636
commit 943697fcd2

View File

@ -474,7 +474,12 @@ def refresh_links_for_backend(backend_name, chunk_size, expiry_seconds):
refreshed = 0 refreshed = 0
for file_doc in to_refresh: for file_doc in to_refresh:
count = proj_coll.count({'_id': file_doc['project']}) project_id = file_doc.get('project')
if project_id is None:
log.debug('Skipping file %s, it has no project.', file_doc['_id'])
continue
count = proj_coll.count({'_id': project_id})
if count == 0: if count == 0:
log.debug('Skipping file %s, project does not exist.', file_doc['_id']) log.debug('Skipping file %s, project does not exist.', file_doc['_id'])
continue continue