From 6f323724ba3daf12fd2c9908f0c23193db39de6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Golonka?= Date: Mon, 16 Sep 2019 15:15:01 +0200 Subject: [PATCH 1/2] Stop removing compiled Python files from user and system configs during update of NVDA. - In addition remove all .dll and manifest files. - stop removing mpr.dll explicitly - it is removed along with all other libraries. --- source/installer.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/source/installer.py b/source/installer.py index 61fdd30be0e..6284df28468 100644 --- a/source/installer.py +++ b/source/installer.py @@ -1,8 +1,8 @@ -#installer.py -#A part of NonVisual Desktop Access (NVDA) -#This file is covered by the GNU General Public License. -#See the file COPYING for more details. -#Copyright (C) 2011-2019 NV Access Limited, Joseph Lee, Babbage B.V. +# -*- coding: UTF-8 -*- +# A part of NonVisual Desktop Access (NVDA) +# This file is covered by the GNU General Public License. +# See the file COPYING for more details. +# Copyright (C) 2011-2019 NV Access Limited, Joseph Lee, Babbage B.V., Ɓukasz Golonka from ctypes import * from ctypes.wintypes import * @@ -23,7 +23,7 @@ import easeOfAccess import COMRegistrationFixes import winKernel -import importlib.machinery + _wsh=None def _getWSH(): global _wsh @@ -200,20 +200,21 @@ def removeOldProgramFiles(destPath): else: os.remove(fn) - # #4235: mpr.dll is a Windows system dll accidentally included with - # earlier versions of NVDA. Its presence causes problems in Windows Vista. - fn = os.path.join(destPath, "mpr.dll") - if os.path.isfile(fn): - tryRemoveFile(fn) - # #9960: If compiled python files from older versions aren't removed correctly, # this could cause strange errors when Python tries to create tracebacks # in a newer version of NVDA. + # However don't touch user and system config. + # Also remove old .dll and .manifest files. for curDestDir,subDirs,files in os.walk(destPath): + subDirs[:] = [x for x in subDirs if os.path.basename(x).lower() not in ( + 'userconfig', + 'systemconfig', + # Do not remove old libraries here. It is done by removeOldLibFiles. + 'lib', + 'lib64', + 'libarm64')] for f in files: - if f.endswith((".pyc", ".pyo", ".pyd")) and not f.endswith(importlib.machinery.EXTENSION_SUFFIXES[0]): - # This also removes compiled files from system config, - # but that is fine. + if f.endswith((".pyc", ".pyo", ".pyd", ".dll", ".manifest")): path=os.path.join(curDestDir, f) log.debug(f"Removing old byte compiled python file: {path!r}") try: From 6f5330d6759fe3ef49f821d0c54d52e4177238ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Golonka?= Date: Mon, 21 Oct 2019 16:52:30 +0200 Subject: [PATCH 2/2] Review actions. --- source/installer.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source/installer.py b/source/installer.py index 6284df28468..5878ed7368c 100644 --- a/source/installer.py +++ b/source/installer.py @@ -206,13 +206,14 @@ def removeOldProgramFiles(destPath): # However don't touch user and system config. # Also remove old .dll and .manifest files. for curDestDir,subDirs,files in os.walk(destPath): - subDirs[:] = [x for x in subDirs if os.path.basename(x).lower() not in ( - 'userconfig', - 'systemconfig', - # Do not remove old libraries here. It is done by removeOldLibFiles. - 'lib', - 'lib64', - 'libarm64')] + if curDestDir == destPath: + subDirs[:] = [x for x in subDirs if os.path.basename(x).lower() not in ( + 'userconfig', + 'systemconfig', + # Do not remove old libraries here. It is done by removeOldLibFiles. + 'lib', + 'lib64', + 'libarm64')] for f in files: if f.endswith((".pyc", ".pyo", ".pyd", ".dll", ".manifest")): path=os.path.join(curDestDir, f)