Prevent write of SERVER_RESTART_REQUIRED setting when importing dataset (#3249)

This commit is contained in:
Oliver 2022-06-24 20:42:55 +10:00 committed by GitHub
parent daf019c13a
commit 5b54979202
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -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")
if not isImportingData():
common.models.InvenTreeSetting.set_setting('SERVER_RESTART_REQUIRED', False, None)
except Exception:
pass

View File

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