From 943697fcd28fefd3fcf14ae118b9c43f8dd21395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 27 Jul 2016 10:50:40 +0200 Subject: [PATCH] refresh_links_for_backend: gracefully handle project-less files. --- pillar/application/modules/file_storage.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pillar/application/modules/file_storage.py b/pillar/application/modules/file_storage.py index 265fef56..3cb24b6c 100644 --- a/pillar/application/modules/file_storage.py +++ b/pillar/application/modules/file_storage.py @@ -474,7 +474,12 @@ def refresh_links_for_backend(backend_name, chunk_size, expiry_seconds): refreshed = 0 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: log.debug('Skipping file %s, project does not exist.', file_doc['_id']) continue