BE: version added to app_state
Some checks failed
docker / docker_dev (push) Has been cancelled

Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
jokob-sk
2025-11-06 22:08:19 +11:00
parent 58de31d0ea
commit cbe5a4a732
3 changed files with 43 additions and 32 deletions

View File

@@ -39,7 +39,8 @@ class app_state_class:
showSpinner=None,
graphQLServerStarted=0,
processScan=False,
pluginsStates=None):
pluginsStates=None,
appVersion=None):
"""
Initialize the application state, optionally overwriting previous values.
@@ -54,6 +55,7 @@ class app_state_class:
graphQLServerStarted (int, optional): Initial GraphQL server timestamp.
processScan (bool, optional): Initial processScan flag.
pluginsStates (dict, optional): Initial plugin states to merge with previous state.
appVersion (str, optional): Application version.
"""
# json file containing the state to communicate with the frontend
stateFile = apiPath + 'app_state.json'
@@ -80,6 +82,7 @@ class app_state_class:
self.graphQLServerStarted = previousState.get("graphQLServerStarted", 0)
self.currentState = previousState.get("currentState", "Init")
self.pluginsStates = previousState.get("pluginsStates", {})
self.appVersion = previousState.get("appVersion", "")
else: # init first time values
self.settingsSaved = 0
self.settingsImported = 0
@@ -90,6 +93,7 @@ class app_state_class:
self.graphQLServerStarted = 0
self.currentState = "Init"
self.pluginsStates = {}
self.appVersion = ""
# Overwrite with provided parameters if supplied
if settingsSaved is not None:
@@ -118,7 +122,8 @@ class app_state_class:
# Optionally ignore or add new plugin entries
# To ignore new plugins, comment out the next line
self.pluginsStates[plugin] = state
if appVersion is not None:
self.appVersion = appVersion
# check for new version every hour and if currently not running new version
if self.isNewVersion is False and self.isNewVersionChecked + 3600 < int(timeNow().timestamp()):
self.isNewVersion = checkNewVersion()
@@ -154,7 +159,8 @@ def updateState(newState = None,
showSpinner = None,
graphQLServerStarted = None,
processScan = None,
pluginsStates=None):
pluginsStates=None,
appVersion=None):
"""
Convenience method to create or update the app state.
@@ -166,6 +172,7 @@ def updateState(newState = None,
graphQLServerStarted (int, optional): Timestamp of GraphQL server start.
processScan (bool, optional): Flag indicating if a scan is active.
pluginsStates (dict, optional): Plugin state updates.
appVersion (str, optional): Application version.
Returns:
app_state_class: Updated state object.
@@ -176,7 +183,8 @@ def updateState(newState = None,
showSpinner,
graphQLServerStarted,
processScan,
pluginsStates)
pluginsStates,
appVersion)
#-------------------------------------------------------------------------------