mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-09-16 08:10:15 -04:00
Refactor config import logic for legacy column references
Ensure legacy column references are renamed only if the config file has changed. Fix unnecessary config scan in importConfigs, was causing the container to run at over 80% CPU. QA tested locally, all test passed!
This commit is contained in:
1 parent
0794bb8ae2
commit
fbc9fcee7e
1 file changed
+5
-5
@@ -230,17 +230,14 @@ def importConfigs(pm, db, all_plugins):
|
||||
# get config file name
|
||||
config_file = Path(fullConfPath)
|
||||
|
||||
# Only import file if the file was modifed since last import.
|
||||
# Only import file if the file was modified since last import.
|
||||
# this avoids time zone issues as we just compare the previous timestamp to the current time stamp
|
||||
|
||||
# rename settings that have changed names due to code cleanup and migration to plugins
|
||||
# renameSettings(config_file)
|
||||
|
||||
# rename legacy DB column references in user config values (e.g. templates, WATCH lists)
|
||||
renameColumnReferences(config_file)
|
||||
|
||||
fileModifiedTime = os.path.getmtime(config_file)
|
||||
|
||||
|
||||
mylog("debug", ["[Import Config] checking config file "])
|
||||
mylog("debug", ["[Import Config] lastImportedConfFile :", conf.lastImportedConfFile],)
|
||||
mylog("debug", ["[Import Config] fileModifiedTime :", fileModifiedTime])
|
||||
@@ -249,6 +246,9 @@ def importConfigs(pm, db, all_plugins):
|
||||
mylog("debug", ["[Import Config] skipping config file import"])
|
||||
return pm, all_plugins, False
|
||||
|
||||
# rename legacy column references only when the config file actually changed
|
||||
renameColumnReferences(config_file)
|
||||
|
||||
# Header
|
||||
updateState("Import config", showSpinner=True)
|
||||
|
||||
|
||||
Reference in new issue
Block a user