BACnet: prevent saving configuration that is same as default, delete it if so.
authorEdouard Tisserant
Mon, 15 Jun 2020 14:34:00 +0200
changeset 2674 a8975ff44cd1
parent 2673 80e7eb44cab4
child 2675 3ca5611d6308
BACnet: prevent saving configuration that is same as default, delete it if so.
bacnet/web_settings.py
--- a/bacnet/web_settings.py	Mon Jun 15 14:29:41 2020 +0200
+++ b/bacnet/web_settings.py	Mon Jun 15 14:34:00 2020 +0200
@@ -166,10 +166,15 @@
 
 def _SetSavedConfiguration(BACnetConfig):
     """ Stores in a file a dictionary containing the BACnet parameter configuration """
-    with open(os.path.realpath(_BACnetConfFilename), 'w') as f:
-        json.dump(BACnetConfig, f, sort_keys=True, indent=4)
     global _SavedConfiguration
-    _SavedConfiguration = BACnetConfig
+
+    if BACnetConfig == _DefaultConfiguration :
+        _DelSavedConfiguration()
+        _SavedConfiguration = None
+    else :
+        with open(os.path.realpath(_BACnetConfFilename), 'w') as f:
+            json.dump(BACnetConfig, f, sort_keys=True, indent=4)
+        _SavedConfiguration = BACnetConfig
 
 
 def _DelSavedConfiguration():