From ab9d5c179353a757779e8cf6195036248825304b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 27 Oct 2016 10:38:02 +0200 Subject: [PATCH] CLI upgrade_attachment_schema: skip already upgraded nodes. --- pillar/cli.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pillar/cli.py b/pillar/cli.py index 73598af9..db004f5d 100644 --- a/pillar/cli.py +++ b/pillar/cli.py @@ -672,7 +672,6 @@ def upgrade_attachment_schema(proj_url=None, all_projects=False): for proj_nt in project['node_types']: nt_name = proj_nt['name'] if nt_name not in nts_by_name: - log.info(' - skipping node type "%s"', nt_name) continue log.info(' - replacing attachment schema on node type "%s"', nt_name) @@ -703,10 +702,14 @@ def upgrade_attachment_schema(proj_url=None, all_projects=False): 'properties.attachments': {'$exists': True}, }) for node in nodes: + attachments = node[u'properties'][u'attachments'] + if isinstance(attachments, dict): + # This node has already been upgraded. + continue + log.info(' - Updating schema on node %s (%s)', node['_id'], node.get('name')) new_atts = {} - - for field_info in node[u'properties'][u'attachments']: + for field_info in attachments: for attachment in field_info.get('files', []): new_atts[attachment[u'slug']] = {u'oid': attachment[u'file']}