From 7cd62527c0bd9b7665d5a7051f42f36336556dc0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 16 Jan 2024 22:12:51 +1100 Subject: [PATCH] Prevent creation of new PluginConfig during data import (#6247) * Prevent creation of new PluginConfig during data import - Fixes race condition which can occur sometimes * typo fix --- InvenTree/plugin/plugin.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/InvenTree/plugin/plugin.py b/InvenTree/plugin/plugin.py index 4c338e3c22..489e114961 100644 --- a/InvenTree/plugin/plugin.py +++ b/InvenTree/plugin/plugin.py @@ -96,6 +96,12 @@ class MetaBase: def plugin_config(self): """Return the PluginConfig object associated with this plugin.""" + import InvenTree.ready + + # Database contains no information yet - return None + if InvenTree.ready.isImportingData(): + return None + try: import plugin.models @@ -104,6 +110,8 @@ class MetaBase: ) except (OperationalError, ProgrammingError): cfg = None + except plugin.models.PluginConfig.DoesNotExist: + cfg = None return cfg