From 4772a6f45d7b3e5b30a4c729a6c56131dbd5f65b Mon Sep 17 00:00:00 2001 From: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:49:57 +1000 Subject: [PATCH] Do not complete add-on installation or removal from the launcher (#17024) Fixes #16837 Summary of the issue: As reported by @CyrilleB79, if one were to update an add-on from the add-on store, then accept an NVDA update before restarting to complete the add-on update, the update will completely clobber the add-on. Upon further investigation, this is because the launcher erroneously attempts to complete add-on installation/removal, but an error is thrown (because it shouldn't be touching the file system) part way through, so it cannot complete successfully. Description of user facing changes If add-ons are pending installation/removal when an update is started, the installation will not affect this, and the installation/removal will proceed when the updated copy of NVDA starts. Description of development approach Added checks for NVDAState.shouldWriteToDisk() to sections of addonHandler._getAvailableAddonsFromPath that alter the filesystem. --- source/addonHandler/__init__.py | 13 +++++++++---- user_docs/en/changes.md | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source/addonHandler/__init__.py b/source/addonHandler/__init__.py index d456d6eabbf..ef7ae939612 100644 --- a/source/addonHandler/__init__.py +++ b/source/addonHandler/__init__.py @@ -337,7 +337,7 @@ def _getAvailableAddonsFromPath( log.debug("Listing add-ons from %s", path) for p in os.listdir(path): if p.endswith(DELETEDIR_SUFFIX): - if isFirstLoad: + if isFirstLoad and NVDAState.shouldWriteToDisk(): removeFailedDeletion(os.path.join(path, p)) continue addon_path = os.path.join(path, p) @@ -351,6 +351,7 @@ def _getAvailableAddonsFromPath( name = a.manifest["name"] if ( isFirstLoad + and NVDAState.shouldWriteToDisk() and name in state[AddonStateCategory.PENDING_REMOVE] and not a.path.endswith(ADDON_PENDINGINSTALL_SUFFIX) ): @@ -360,9 +361,13 @@ def _getAvailableAddonsFromPath( except RuntimeError: log.exception(f"Failed to remove {name} add-on") _failedPendingRemovals.add(name) - if isFirstLoad and ( - name in state[AddonStateCategory.PENDING_INSTALL] - or a.path.endswith(ADDON_PENDINGINSTALL_SUFFIX) + if ( + isFirstLoad + and NVDAState.shouldWriteToDisk() + and ( + name in state[AddonStateCategory.PENDING_INSTALL] + or a.path.endswith(ADDON_PENDINGINSTALL_SUFFIX) + ) ): newPath = a.completeInstall() if newPath: diff --git a/user_docs/en/changes.md b/user_docs/en/changes.md index a929485a220..c2fafcd3b50 100644 --- a/user_docs/en/changes.md +++ b/user_docs/en/changes.md @@ -42,6 +42,7 @@ The available options are: * Improvements in Microsoft PowerPoint: (#17004) * It is now possible to use braille display routing keys to move the text cursor. (#9101) * It is now possible to use the review cursor selection commands to select text. +* Updating NVDA while add-on updates are pending no longer results in the add-on being removed. (#16837) ### Changes for Developers