Skip to content

Commit

Permalink
Retry explicitly, when the command is unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
tsterbak committed May 10, 2023
1 parent cdb5683 commit 9647bd1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion openandroidinstaller/tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,14 @@ def adb_twrp_format_data(bin_path: Path) -> TerminalResponse:
If `format data` fails (for example because of old TWRP versions) we fall back to `wipe data`.
"""
unknown_command = False
for line in run_command("adb shell twrp format data", bin_path):
if "Unrecognized script command" in line:
unknown_command = True
yield line
if (type(line) == bool) and not line:

# if it fails because the command is unknown, retry with wipe data.
if unknown_command:
logger.info(
"Factory reset with `adb twrp format data` failed. Trying `adb twrp wipe data` now."
)
Expand Down

0 comments on commit 9647bd1

Please sign in to comment.