Repository navigation
Fix the metered networks checkbox so it saves and survives a restart - #2573
Open
theluckystrike wants to merge 1 commit into
Open
theluckystrike wants to merge 1 commit into
theluckystrike wants to merge 1 commit into
Conversation
Ticking "Run backups over metered networks" on Schedule > Networks never reached the database, so dont_run_on_metered_networks stayed 1 and create.py skipped every backup on a metered connection (issue borgbase#2557). QCheckBox.stateChanged passes a plain int in PyQt6, and an int never equals the Qt.CheckState enum, so every click stored True. The handler then reset the box from a profile fetched before the save, which flipped it back. populate_wifi never set the box at all, so after a restart or a profile switch it showed unchecked whatever the database held. I convert the state with Qt.CheckState(state) as misc_tab.py and extract.py already do, drop the stale setChecked call, and set the box from the profile in populate_wifi with signals blocked so loading writes nothing. The .ui file, the model default and migrations are unchanged. tests/unit/test_networks_page.py covers the value shown on load and clicks persisting in both directions. I ran the following on macOS 26.6 with Python 3.12.13, PyQt6 6.10.1, borgbackup 1.4.4 and QT_QPA_PLATFORM=offscreen. Offscreen Qt on macOS leaves NSApp unset, so pytest ran through a small wrapper that calls NSApplication.sharedApplication() first. Master c14a801 with the new test file $ pytest tests/unit/test_networks_page.py -q FAILED tests/unit/test_networks_page.py::test_metered_checkbox_reflects_profile_on_load FAILED tests/unit/test_networks_page.py::test_metered_checkbox_click_persists 2 failed in 13.64s This commit $ pytest tests/unit/test_networks_page.py -q 2 passed in 1.34s $ pytest --cov=vorta tests/unit 306 passed, 7 skipped, 6 warnings in 101.81s (0:01:41) $ pre-commit run --all-files --show-diff-on-failure ruff.....................................................................Passed ruff-format..............................................................Passed $ mypy src/vorta/store/ src/vorta/network_status/ Success: no issues found in 9 source files End to end I started Vorta through vorta.__main__.main() in development mode on a fresh config dir, opened Schedule > Networks, clicked the checkbox indicator with QTest.mouseClick, quit, and read backupprofilemodel.dont_run_on_metered_networks with sqlite3 after each separate process start. master c14a801 box on start box at quit db start False False 1 start, click False False 1 restart False False 1 this commit box on start box at quit db start False False 1 start, click False True 0 restart True True 0 restart, click True False 1 restart False False 1 I didn't run make test-unit through nox (I ran the same pytest call in a uv venv), the Linux xvfb job, the integration tests and a click in a visible macOS window here. Signed-off-by: Michael Lip <51033404+theluckystrike@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The "Run backups over metered networks" checkbox on the Networks page doesn't store a change and shows the wrong state after a restart.
QCheckBox.stateChangedsends an int in PyQt6.on_metered_networks_state_changedcompared it with theQt.CheckState.Checkedenum, which never matches, so every click storeddont_run_on_metered_networks = True.populate_wifinever set the checkbox from the profile, so after a restart or profile switch it always showed unchecked.The handler now converts the value with
Qt.CheckState(state), the same waymisc_tab.pyandextract.pydo, and drops the stale reset.populate_wifisets the checkbox from the profile with signals blocked, so loading the page writes nothing. The .ui file, the model default and the migrations are unchanged.Related Issue
Fixes #2557. The reporter traced the problem to
networks_page.pyand the stored value inbackupprofilemodel, and both match what I found.Motivation and Context
With the old code a user on a phone hotspot can't allow metered backups. Every scheduled run logs
Backup skipped: Not running backup over metered connection.and the profile keepsdont_run_on_metered_networks = 1whatever the checkbox shows.How Has This Been Tested?
New
tests/unit/test_networks_page.pyhas 2 tests. The first loads the window with metered backups allowed and expects a ticked box. The second clicks the box twice and reads the stored profile value after each click, so both directions are covered.I ran everything on macOS 26.6, Python 3.12.13, PyQt6 6.10.1, borgbackup 1.4.4, with
QT_QPA_PLATFORM=offscreen. Offscreen Qt on macOS leavesNSAppunset, so pytest ran through a small wrapper that callsNSApplication.sharedApplication()first.End to end I started Vorta through
vorta.__main__.main()with--development <dir>, opened Schedule > Networks, clicked the checkbox indicator withQTest.mouseClick, quit, and readbackupprofilemodel.dont_run_on_metered_networkswith sqlite3 after each separate process start.Types of changes
Checklist
I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.