Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NVDA fails to uninstall add-on which contains read-only files #12824

Open
lukaszgo1 opened this issue Sep 9, 2021 · 4 comments
Open

NVDA fails to uninstall add-on which contains read-only files #12824

lukaszgo1 opened this issue Sep 9, 2021 · 4 comments
Labels
Addon/management In NVDA management of addons by users. feature/addon-store Features / behavior of the add-on Store p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.

Comments

@lukaszgo1
Copy link
Contributor

Discovered when working on #12792

Steps to reproduce:

  1. Install an add-on containing read-only files (in my case this was because I've been using git to version the content of the plugin and git marks some of its hidden files as read-only).
  2. Try to uninstall the plugin.

Actual behavior:

NVDA fails to finish uninstallation and asks user to remove the folder manually.

Expected behavior:

Plugin should uninstall normally since even though it contains read-only files Windows Explorer can remove its folder successfully.

System configuration

NVDA installed/portable/running from source:

Tested from sources but probably not relevant

NVDA version:

Latest master as of September 9th.

Windows version:

N/A

Name and version of other software in use when reproducing the issue:

None

Other information about your system:

None relevant

Other questions

Does the issue still occur after restarting your computer?

Yes

Have you tried any other versions of NVDA? If so, please report their behaviors.

No, but this behavior is not new

If add-ons are disabled, is your problem still occurring?

No but this is about NVDA's interaction with add-ons

Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?

Not tried since it is not relevant.

Technical:

The problem occurs because we're using shutil.rmtree to remove the add-on directory and this function is incapable of removing read-only files. The only solution is to use different way of removing the folder. My first thought was to use SHFileOperationW we even have necessary structures defined in shellapi. Unfortunately while this solution works from the standard Python interpreter it cannot be used from NVDA currently. After a lot of research it turns out that Python 3.5 up to 3.7 which we're using has a bug which prevents usages of null terminated strings in ctypes structures and SHFileOperationW uses null as a path separator.
I see the following ways of dealing with this problem:

  • Wait for a Python upgrade and then use SHFileOperationW - the bug linked above is fixed in 3.8 and up though given the current problems with moving to more recent version of Python this may take a while.
  • Implement a C++ wrapper around SHFileOperationW in NVDAHelper and use it to remove the directory - we have some utility functions in NVDAHelper so there is a precedent for this.
  • Try to use IFileOperation which is a more moder replacement for SHFileOperationW though it seems to be much harder to use in general and accessing it from Python makes it even harder. On the flip side it does not require nulls as path separator.
@feerrenrut feerrenrut added the Addon/management In NVDA management of addons by users. label Sep 10, 2021
@Adriani90
Copy link
Collaborator

cc: @seanbudd

@seanbudd
Copy link
Member

Given this is blocked by a python upgrade I am adding this to the 2024.1 milestone

@seanbudd seanbudd added this to the 2024.1 milestone Apr 12, 2023
@seanbudd
Copy link
Member

Now that we are on Python 3.11 we plan to take this on, unless you plan to @lukaszgo1

@lukaszgo1
Copy link
Contributor Author

@seanbudd From my initial comment, this is (or was) blocked by the Python 3.11 upgrade if and only if, we prefer to use SHFileOperationW, which is legacy, and no longer recommended by Microsoft for applications which do not need to target Windows XP. I can work on this and try to use IFileOperation which is the more modern replacement, though I haven't worked with COM that much, so it might take a while. On the other hand I don't think there is a particular rush, as this issue is encountered pretty rarely.

@seanbudd seanbudd removed this from the 2024.1 milestone Nov 22, 2023
@seanbudd seanbudd added p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation. feature/addon-store Features / behavior of the add-on Store labels Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Addon/management In NVDA management of addons by users. feature/addon-store Features / behavior of the add-on Store p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.
Projects
None yet
Development

No branches or pull requests

4 participants