# HG changeset patch # User Goffi # Date 1566574046 -7200 # Node ID 4179ed660a85b917923f6e3ab44cb92974a0d1df # Parent ccb2a22ea0fc04d0645e053faad77ca189f709a5 backend: fixed publishing with "consistent_publisher" when no item was previously available diff -r ccb2a22ea0fc -r 4179ed660a85 sat_pubsub/backend.py --- a/sat_pubsub/backend.py Fri Aug 16 12:53:33 2019 +0200 +++ b/sat_pubsub/backend.py Fri Aug 23 17:27:26 2019 +0200 @@ -457,19 +457,22 @@ if affiliation == 'owner' or self.isAdmin(requestor): if configuration[const.OPT_CONSISTENT_PUBLISHER]: pub_map = yield node.getItemsPublishers(itemIdentifiers) - publishers = set(pub_map.values()) - if len(publishers) != 1: - # TODO: handle multiple items publishing (from several - # publishers) - raise error.NoPublishing( - "consistent_publisher is currently only possible when " - "publishing items from a single publisher. Try to " - "publish one item at a time") - # we replace requestor and new payload's publisher by original - # item publisher to keep publisher consistent - requestor = publishers.pop() - for item in items: - item['publisher'] = requestor.full() + if pub_map: + # if we have existing items, we replace publishers with + # original one to stay consistent + publishers = set(pub_map.values()) + if len(publishers) != 1: + # TODO: handle multiple items publishing (from several + # publishers) + raise error.NoPublishing( + "consistent_publisher is currently only possible when " + "publishing items from a single publisher. Try to " + "publish one item at a time") + # we replace requestor and new payload's publisher by original + # item publisher to keep publisher consistent + requestor = publishers.pop() + for item in items: + item['publisher'] = requestor.full() else: # we don't want a publisher to overwrite the item # of an other publisher