From 5b54979202b1b7ab01438d13e739845ecf9a95ce Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 24 Jun 2022 20:42:55 +1000 Subject: [PATCH] Prevent write of SERVER_RESTART_REQUIRED setting when importing dataset (#3249) --- InvenTree/common/apps.py | 6 +++++- InvenTree/common/models.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/InvenTree/common/apps.py b/InvenTree/common/apps.py index 331ea5bf7d..084b101bf6 100644 --- a/InvenTree/common/apps.py +++ b/InvenTree/common/apps.py @@ -4,6 +4,8 @@ import logging from django.apps import AppConfig +from InvenTree.ready import isImportingData + logger = logging.getLogger('inventree') @@ -26,6 +28,8 @@ class CommonConfig(AppConfig): if common.models.InvenTreeSetting.get_setting('SERVER_RESTART_REQUIRED', backup_value=False, create=False, cache=False): logger.info("Clearing SERVER_RESTART_REQUIRED flag") - common.models.InvenTreeSetting.set_setting('SERVER_RESTART_REQUIRED', False, None) + + if not isImportingData(): + common.models.InvenTreeSetting.set_setting('SERVER_RESTART_REQUIRED', False, None) except Exception: pass diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 22015676e9..038972e21a 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -37,6 +37,7 @@ from rest_framework.exceptions import PermissionDenied import InvenTree.fields import InvenTree.helpers +import InvenTree.ready import InvenTree.validators logger = logging.getLogger('inventree') @@ -748,7 +749,7 @@ class InvenTreeSetting(BaseInvenTreeSetting): """ super().save() - if self.requires_restart(): + if self.requires_restart() and not InvenTree.ready.isImportingData(): InvenTreeSetting.set_setting('SERVER_RESTART_REQUIRED', True, None) """