--- a/src/eric7/PluginManager/PluginRepositoryDialog.py Fri Dec 23 11:37:49 2022 +0100 +++ b/src/eric7/PluginManager/PluginRepositoryDialog.py Sat Dec 24 17:31:46 2022 +0100 @@ -1082,33 +1082,35 @@ pluginsRegister.append(pluginName) downloadPath = Preferences.getPluginManager("DownloadPath") - downloads = {} # plug-in name as key, file name as value + downloads = {} # plug-in name as key, file name and version as value - # TODO: replace os.listdir() with os.scandir() # step 1: extract plug-ins and downloaded files - for pluginFile in os.listdir(downloadPath): - if not os.path.isfile(os.path.join(downloadPath, pluginFile)): - continue + with os.scandir(downloadPath) as dirEntriesIterator: + for pluginFile in dirEntriesIterator: + if not pluginFile.is_file(): + continue - try: - pluginName, pluginVersion = pluginFile.replace(".zip", "").rsplit("-", 1) - pluginVersionList = re.split("[._-]", pluginVersion) - for index in range(len(pluginVersionList)): - try: - pluginVersionList[index] = int(pluginVersionList[index]) - except ValueError: - # use default of 0 - pluginVersionList[index] = 0 - except ValueError: - # rsplit() returned just one entry, i.e. file name doesn't contain - # version info separated by '-' - # => assume version 0.0.0 - pluginName = pluginFile.replace(".zip", "") - pluginVersionList = [0, 0, 0] + try: + pluginName, pluginVersion = pluginFile.name.replace(".zip", "").rsplit( + "-", 1 + ) + pluginVersionList = re.split("[._-]", pluginVersion) + for index in range(len(pluginVersionList)): + try: + pluginVersionList[index] = int(pluginVersionList[index]) + except ValueError: + # use default of 0 + pluginVersionList[index] = 0 + except ValueError: + # rsplit() returned just one entry, i.e. file name doesn't contain + # version info separated by '-' + # => assume version 0.0.0 + pluginName = pluginFile.replace(".zip", "") + pluginVersionList = [0, 0, 0] - if pluginName not in downloads: - downloads[pluginName] = [] - downloads[pluginName].append((pluginFile, tuple(pluginVersionList))) + if pluginName not in downloads: + downloads[pluginName] = [] + downloads[pluginName].append((pluginFile, tuple(pluginVersionList))) # step 2: delete old entries hiddenPlugins = Preferences.getPluginManager("HiddenPlugins")