From ab2f9661d1138494f255b47533f38dd16f716e3e Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 13 May 2022 18:44:54 +0200 Subject: [PATCH] plugin pubsub cache: new `resync` argument to force resynchronisation in `synchronize` --- sat/plugins/plugin_pubsub_cache.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sat/plugins/plugin_pubsub_cache.py b/sat/plugins/plugin_pubsub_cache.py index d55f376d..1c5a6bd5 100644 --- a/sat/plugins/plugin_pubsub_cache.py +++ b/sat/plugins/plugin_pubsub_cache.py @@ -707,16 +707,17 @@ class PubsubCache: self, client: SatXMPPEntity, service: jid.JID, - node: str + node: str, + resync: bool = True ) -> None: """Synchronise a node with a pubsub service - If the node is already synchronised, it will be resynchronised (all items will be - deleted and re-downloaded). - The node will be synchronised even if there is no matching analyser. Note that when a node is synchronised, it is automatically subscribed. + @param resync: if True and the node is already synchronised, it will be + resynchronised (all items will be deleted and re-downloaded). + """ pubsub_node = await self.host.memory.storage.getPubsubNode( client, service, node @@ -735,6 +736,9 @@ class PubsubCache: analyser=analyse.get("name"), type_=analyse.get("type"), ) + elif not resync: + # the node exists, nothing to do + return if ((pubsub_node.sync_state == SyncState.IN_PROGRESS or (service, node) in self.in_progress)):