Skip to content

Commit 10103d6

Browse files
dbieberclaude
andcommitted
Optimize settings save by skipping unchanged values
- Compare WiFi networks before running reconfigure_wifi - Skip saving other settings that haven't changed - Add diagnostic logs to track when settings are changed 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f977ff9 commit 10103d6

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

gonotego/settings/server.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,26 @@ def do_POST(self):
175175
try:
176176
# Handle WiFi networks specially
177177
if key == 'WIFI_NETWORKS':
178-
wifi.save_networks(value)
179-
wifi.update_wpa_supplicant_config()
180-
wifi.reconfigure_wifi()
178+
# Get current networks before saving the new ones
179+
current_networks = wifi.get_networks()
180+
181+
# Compare current and new networks
182+
if json.dumps(current_networks) != json.dumps(value):
183+
# Only save and reconfigure if networks have actually changed
184+
wifi.save_networks(value)
185+
wifi.update_wpa_supplicant_config()
186+
wifi.reconfigure_wifi()
187+
print("WiFi networks changed, reconfigured WiFi")
188+
else:
189+
print("WiFi networks unchanged, skipping reconfiguration")
181190
else:
182-
# For all other settings, just use settings.set
183-
settings.set(key, value)
191+
# For all other settings, only save if changed
192+
current_value = settings.get(key)
193+
if str(current_value) != str(value):
194+
settings.set(key, value)
195+
print(f"Setting {key} changed, saved new value")
196+
else:
197+
print(f"Setting {key} unchanged, skipping save")
184198
except Exception as e:
185199
print(f"Error setting {key}: {e}")
186200

0 commit comments

Comments
 (0)