NVDA fails to uninstall add-on which contains read-only files #12824
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.
Discovered when working on #12792
Steps to reproduce:
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 useSHFileOperationW
we even have necessary structures defined inshellapi
. 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 andSHFileOperationW
uses null as a path separator.I see the following ways of dealing with this problem:
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.SHFileOperationW
in NVDAHelper and use it to remove the directory - we have some utility functions in NVDAHelper so there is a precedent for this.IFileOperation
which is a more moder replacement forSHFileOperationW
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.The text was updated successfully, but these errors were encountered: