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
This commit is contained in:
Oliver 2024-01-16 22:12:51 +11:00 committed by GitHub
parent 716e577916
commit 7cd62527c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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