From 18c790f986d62e99edeb62314a7373a21be7da1e Mon Sep 17 00:00:00 2001 From: "Piotr F. Mieszkowski" Date: Sun, 23 Oct 2022 13:51:42 +0200 Subject: [PATCH] Only reload on pubring.kbx file modifications --- lacre/keyring.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lacre/keyring.py b/lacre/keyring.py index 6a37c96..9baa75e 100644 --- a/lacre/keyring.py +++ b/lacre/keyring.py @@ -8,7 +8,7 @@ import lacre.text as text import lacre.config as conf import logging from os import stat -from watchdog.events import FileSystemEventHandler +from watchdog.events import FileSystemEventHandler, FileSystemEvent from asyncio import Semaphore, run import copy @@ -141,10 +141,11 @@ class KeyringModificationListener(FileSystemEventHandler): """Initialise a listener with a callback to be executed upon each change.""" self._keyring = keyring - def handle(self, event): + def handle(self, event: FileSystemEvent): """Reload keys upon FS event.""" - LOG.debug(f'Reloading on event {event!r}') - self._keyring.reload() + if 'pubring.kbx' in event.src_path: + LOG.debug(f'Reloading on event {event!r}') + self._keyring.reload() # All methods should do the same: reload the key cache. # on_created = handle