Keep the edit from the point the device accepted the session

This commit is contained in:
J. Nick Koston
2026-10-13 07:28:38 -10:00
committed by GitHub
parent c3babe49b4
commit e0b7a84957
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -189,9 +189,9 @@ def command_rotate_key(args: argparse.Namespace, config: ConfigType) -> int | No
if run_external_process(*ESPHOME_COMMAND, *cli_args) != 0:
return fail("Compiling with the new key failed")
def device_reached() -> None:
# The upload may commit from here on; the edited config reaches
# the device on either key
def image_sent() -> None:
# The device accepted the session and may commit from here on;
# the edited config reaches it on either key
nonlocal uploaded
uploaded = True
@@ -202,7 +202,7 @@ def command_rotate_key(args: argparse.Namespace, config: ConfigType) -> int | No
CORE.firmware_bin,
noise_psk=old_key,
plaintext_fallback=False,
on_connect=device_reached,
on_upload_start=image_sent,
)
if rc != 0:
return fail(
+2 -2
View File
@@ -122,7 +122,7 @@ def env(tmp_path: Path) -> Generator[dict[str, Mock]]:
def upload_after_connecting(
*_args: Any, **kwargs: Any
) -> tuple[int, str | None]:
kwargs["on_connect"]()
kwargs["on_upload_start"]()
return upload.return_value
upload.side_effect = upload_after_connecting
@@ -159,7 +159,7 @@ def test_success(env: dict[str, Mock], capfd: pytest.CaptureFixture[str]) -> Non
CORE.firmware_bin,
noise_psk=OLD_KEY,
plaintext_fallback=False,
on_connect=ANY,
on_upload_start=ANY,
)
out = capfd.readouterr().out
assert NEW_KEY in out