Fail earlier if the ota update file isn't found

This commit is contained in:
Ian McEwen
2026-06-25 14:28:32 -07:00
parent f0de977be5
commit 7fc69e957c
2 changed files with 8 additions and 0 deletions

View File

@@ -1383,6 +1383,11 @@ def common():
if not stripped_ham_name:
meshtastic.util.our_exit("ERROR: Ham radio callsign cannot be empty or contain only whitespace characters")
# Early validation for OTA firmware file before attempting device connection
if hasattr(args, 'ota_update') and args.ota_update is not None:
if not os.path.isfile(args.ota_update):
meshtastic.util.our_exit(f"Error: OTA firmware file not found: {args.ota_update}", 1)
if have_powermon:
create_power_meter()

View File

@@ -3157,6 +3157,9 @@ def test_main_ota_update_file_not_found(capsys):
assert pytest_wrapped_e.type == SystemExit
assert pytest_wrapped_e.value.code == 1
out, err = capsys.readouterr()
assert "OTA firmware file not found" in out
assert "/nonexistent/firmware.bin" in out
@pytest.mark.unit