Move gui/cli JSON persistence into config #173
Loading…
Reference in a new issue
No description provided.
Delete branch "json-persistence"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The #83 seam-2 move (#126): the gui and cli each carried their own
load_jsoncopy plus a dozen inlinejson.dumpsites for the five state files. Found surveying for #23 and filed as #139:del_providerpopped the provider's entry fromprotocol_dictbut wrote onlyserver.json, so the deleted protocol entry came back from disk on the next start. The cli'sdelete_providerpath turned out to have the same hole. On top of that,resources/default_config.jsonduplicatedconfig.default_settingsas a stale subset (missingno_dnsmasq,dns_off,bypass_networks).Fix
config.load_json/config.save_jsonplus per-file path constants (SERVER_FILE,PROTOCOL_FILE,PROFILE_FILE,BYPASS_APPS_FILE,LAST_SERVER_FILE,CONFIG_FILE) andJSON_FILE_LISTnow live in config, which already owned the service side of the same job. config stays Qt-free per the #83 placement rule, so the cli keeps importing it. Bothload_jsoncopies and every inline dump site are gone;load_configreuses the shared helper. Theserver.json/protocol.jsoncall sites pass to the #125 catalog when that lands.protocol.jsonafter popping the provider's entry (#139).default_config.jsonis deleted (also from setup.py and the PKGBUILD); the cli'sget_configgoes throughload_configlike every other consumer, which also letsenable/disableset keys a staleconfig.jsondoesn't carry.load_configdeep-copies defaulted values so appending to a defaultedbypass_networkscan't rewrite the template.Edge notes, detailed in the commit bodies: the cli's
arguments()locals namedconfighad to becomeconf(module shadowing), andload_configno longer aliasesdefault_settingson fallback.Verification
tests/test_config.pycovers round-trip, missing-file and corrupt-file behavior (the #162 log-level contract moved there from the gui tests),load_config's defaults merge, and that defaulted values don't alias the template.TestDelProviderregression tests assert both halves of a deletion survive a restart, including a provider with no protocol entry.ruff check --select E9,F63,F7,F82 .) pass.build-branch-and-install.sh: package no longer shipsdefault_config.json; protocol flips, favourites and provider deletion persist correctly (#139 scenario reproduced with an override-protocol entry on a custom provider — entry removed on delete, no resurrection after relaunch);--show-optionsshows the merged defaults;--disable ping/--enable pinground-trip through cfgupdate and persist — the first successful run of these flags ever; gui connects recordlast_server.jsoncorrectly across consecutive servers with the hop key preserved.Related fixes (found along the way, technically out of scope)
applyoptionswas broken since upstream: it calledself.dbus_call, a methodAqomuiClinever defined, andload_firewallwithout the stage argument the D-Bus signature requires — so--enable/--disable/--set-alt-dnshad never worked. Both repaired; surfaced by the first live test of those flags during verification.GPL-3.0-or-later). Surfaced by the verification build.Closes #126. Closes #139.
🤖 Generated with Claude Code
fbb3f093281c69b09c84