comparison sat/plugins/plugin_pubsub_cache.py @ 3760:74f436e856ff

plugin pubsub cache: new `resync` argument to force resynchronisation in `synchronize`
author Goffi <goffi@goffi.org>
date Fri, 13 May 2022 18:44:54 +0200
parents c4881833cf8a
children 604b6acaee22
comparison
equal deleted inserted replaced
3759:c4881833cf8a 3760:74f436e856ff
705 705
706 async def synchronise( 706 async def synchronise(
707 self, 707 self,
708 client: SatXMPPEntity, 708 client: SatXMPPEntity,
709 service: jid.JID, 709 service: jid.JID,
710 node: str 710 node: str,
711 resync: bool = True
711 ) -> None: 712 ) -> None:
712 """Synchronise a node with a pubsub service 713 """Synchronise a node with a pubsub service
713 714
714 If the node is already synchronised, it will be resynchronised (all items will be
715 deleted and re-downloaded).
716
717 The node will be synchronised even if there is no matching analyser. 715 The node will be synchronised even if there is no matching analyser.
718 716
719 Note that when a node is synchronised, it is automatically subscribed. 717 Note that when a node is synchronised, it is automatically subscribed.
718 @param resync: if True and the node is already synchronised, it will be
719 resynchronised (all items will be deleted and re-downloaded).
720
720 """ 721 """
721 pubsub_node = await self.host.memory.storage.getPubsubNode( 722 pubsub_node = await self.host.memory.storage.getPubsubNode(
722 client, service, node 723 client, service, node
723 ) 724 )
724 if pubsub_node is None: 725 if pubsub_node is None:
733 service, 734 service,
734 node, 735 node,
735 analyser=analyse.get("name"), 736 analyser=analyse.get("name"),
736 type_=analyse.get("type"), 737 type_=analyse.get("type"),
737 ) 738 )
739 elif not resync:
740 # the node exists, nothing to do
741 return
738 742
739 if ((pubsub_node.sync_state == SyncState.IN_PROGRESS 743 if ((pubsub_node.sync_state == SyncState.IN_PROGRESS
740 or (service, node) in self.in_progress)): 744 or (service, node) in self.in_progress)):
741 log.warning( 745 log.warning(
742 _( 746 _(