--- a/PluginManager/PluginRepositoryDialog.py Sat Dec 08 18:29:28 2018 +0100 +++ b/PluginManager/PluginRepositoryDialog.py Sat Dec 08 18:54:11 2018 +0100 @@ -894,6 +894,26 @@ @param quiet flag indicating quiet operations @type bool """ + pluginsRegister = [] # list of plug-ins contained in the repository + + def registerPlugin(name, short, description, url, author, version, + filename, status): + """ + Method to register a plug-in's data. + + @param name data for the name field (string) + @param short data for the short field (string) + @param description data for the description field (list of strings) + @param url data for the url field (string) + @param author data for the author field (string) + @param version data for the version field (string) + @param filename data for the filename field (string) + @param status status of the plugin (string [stable, unstable, unknown]) + """ + pluginName = os.path.splitext(url.rsplit("/", 1)[1])[0] + if pluginName not in pluginsRegister: + pluginsRegister.append(pluginName) + downloadPath = Preferences.getPluginManager("DownloadPath") downloads = {} # plug-in name as key, file name as value @@ -949,3 +969,33 @@ """<p>The plugin download <b>{0}</b> could""" """ not be deleted.</p><p>Reason: {1}</p>""") .format(removeFile, str(err))) + + # step 3: delete entries of obsolete plug-ins + pluginRepositoryFile = os.path.join(Utilities.getConfigDir(), + "PluginRepository") + if os.path.exists(pluginRepositoryFile): + f = QFile(pluginRepositoryFile) + if f.open(QIODevice.ReadOnly): + from E5XML.PluginRepositoryReader import PluginRepositoryReader + reader = PluginRepositoryReader(f, registerPlugin) + reader.readXML() + + for pluginName in downloads: + if pluginName not in pluginsRegister: + removeFiles = [f[0] for f in downloads[pluginName]] + for removeFile in removeFiles: + try: + os.remove(os.path.join(downloadPath, removeFile)) + except (IOError, OSError) as err: + if not quiet: + E5MessageBox.critical( + None, + QCoreApplication.translate( + "PluginRepositoryWidget", + "Cleanup of Plugin Downloads"), + QCoreApplication.translate( + "PluginRepositoryWidget", + "<p>The plugin download <b>{0}</b>" + " could not be deleted.</p>" + "<p>Reason: {1}</p>""") + .format(removeFile, str(err)))