Skip to content

Commit 9647bd1

Browse files
committed
Retry explicitly, when the command is unknown
1 parent cdb5683 commit 9647bd1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

openandroidinstaller/tooling.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,14 @@ def adb_twrp_format_data(bin_path: Path) -> TerminalResponse:
181181
182182
If `format data` fails (for example because of old TWRP versions) we fall back to `wipe data`.
183183
"""
184+
unknown_command = False
184185
for line in run_command("adb shell twrp format data", bin_path):
186+
if "Unrecognized script command" in line:
187+
unknown_command = True
185188
yield line
186-
if (type(line) == bool) and not line:
189+
190+
# if it fails because the command is unknown, retry with wipe data.
191+
if unknown_command:
187192
logger.info(
188193
"Factory reset with `adb twrp format data` failed. Trying `adb twrp wipe data` now."
189194
)

0 commit comments

Comments
 (0)