Skip to content

Commit

Permalink
nk3/update: add pre_bootloader_hint for update process
Browse files Browse the repository at this point in the history
  • Loading branch information
daringer committed Jun 18, 2024
1 parent be816b0 commit 1fd5b52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pynitrokey/cli/nk3/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def request_repeated_update(self) -> Exception:
)
return Abort()

def pre_bootloader_hint(self) -> None:
pass

def request_bootloader_confirmation(self) -> None:
local_print("")
local_print(
Expand Down
13 changes: 10 additions & 3 deletions pynitrokey/nk3/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ def confirm_update_same_version(self, version: Version) -> None:
pass

@abstractmethod
def request_repeated_update(self) -> Exception:
def request_repeated_update(self) -> Optional[Exception]:
pass

@abstractmethod
def pre_bootloader_hint(self) -> None:
pass

@abstractmethod
Expand Down Expand Up @@ -329,11 +333,14 @@ def _get_bootloader(
# needed for udev to properly handle new device
time.sleep(1)

if platform.system() == "Darwin":
maybe_exc = self.ui.request_repeated_update()
if platform.system() == "Darwin" and maybe_exc is not None:
# Currently there is an issue with device enumeration after reboot on macOS, see
# <https://github.com/Nitrokey/pynitrokey/issues/145>. To avoid this issue, we
# cancel the command now and ask the user to run it again.
raise self.ui.request_repeated_update()
raise maybe_exc

self.ui.pre_bootloader_hint()

exc = None
for t in Retries(3):
Expand Down

0 comments on commit 1fd5b52

Please sign in to comment.