Skip to content

Commit

Permalink
cli: restore: fix exception not being caught correctly
Browse files Browse the repository at this point in the history
the exception would be getting raised by `usbmux.list_devices()`, not by `create_using_usbmux()`
  • Loading branch information
m1stadev committed Apr 14, 2024
1 parent 67065b2 commit ef81d4a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions pymobiledevice3/cli/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,20 @@ def device(ctx, param, value):

ecid = value
logger.debug('searching among connected devices via lockdownd')
for device in usbmux.list_devices():
try:
lockdown = create_using_usbmux(serial=device.serial, connection_type='USB')
except (ConnectionFailedError, ConnectionFailedToUsbmuxdError, IncorrectModeError):
continue
if (ecid is None) or (lockdown.ecid == value):
logger.debug('found device')
return lockdown
else:
continue
try:
for device in usbmux.list_devices():
try:
lockdown = create_using_usbmux(serial=device.serial, connection_type='USB')
except (ConnectionFailedError, IncorrectModeError):
continue
if (ecid is None) or (lockdown.ecid == value):
logger.debug('found device')
return lockdown
else:
continue
except ConnectionFailedToUsbmuxdError:
pass

logger.debug('waiting for device to be available in Recovery mode')
return IRecv(ecid=ecid)

Expand Down

0 comments on commit ef81d4a

Please sign in to comment.