fix initial startup phase

This commit is contained in:
Matthias 2021-11-14 23:49:00 +01:00
parent eb02a85154
commit 47bb9466b7
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
2 changed files with 12 additions and 4 deletions

View File

@ -865,7 +865,7 @@ INTEGRATION_PLUGINS = {}
INTEGRATION_PLUGINS_INACTIVE = {}
INTEGRATION_PLUGIN_GLOBALSETTING = {}
INTEGRATION_APPS_LOADED = False # Marks if apps were reloaded yet
INTEGRATION_APPS_LOADING = True # Marks if apps were reloaded yet
INTEGRATION_PLUGINS_RELOADING = False
INTEGRATION_APPS_PATHS = [] # Holds all added plugin_paths

View File

@ -172,9 +172,8 @@ class PluginAppConfig(AppConfig):
def activate_integration_app(self, plugins):
from common.models import InvenTreeSetting
if settings.PLUGIN_TESTING or ((not settings.INTEGRATION_APPS_LOADED) and InvenTreeSetting.get_setting('ENABLE_PLUGINS_APP')):
if settings.PLUGIN_TESTING or (settings.INTEGRATION_APPS_LOADING and InvenTreeSetting.get_setting('ENABLE_PLUGINS_APP')):
logger.info('Registering IntegrationPlugin apps')
settings.INTEGRATION_APPS_LOADED = True # ensure this section will not run again
apps_changed = False
# add them to the INSTALLED_APPS
@ -188,6 +187,9 @@ class PluginAppConfig(AppConfig):
if apps_changed:
# if apps were changed reload
if settings.INTEGRATION_APPS_LOADING:
settings.INTEGRATION_APPS_LOADING = False
self._reload_apps(populate=True)
self._reload_apps()
# update urls
self._update_urls()
@ -224,7 +226,13 @@ class PluginAppConfig(AppConfig):
break
print('done')
def _reload_apps(self):
def _reload_apps(self, populate: bool = False):
if populate:
apps.app_configs = OrderedDict()
apps.apps_ready = apps.models_ready = apps.loading = apps.ready = False
apps.clear_cache()
apps.populate(settings.INSTALLED_APPS)
return
settings.INTEGRATION_PLUGINS_RELOADING = True
apps.set_installed_apps(settings.INSTALLED_APPS)
settings.INTEGRATION_PLUGINS_RELOADING = False