From 56dc2eb96ee10f324d351d0be55dc21df45dee85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 22 Aug 2012 16:19:22 +0200 Subject: [PATCH] remoteSearch: Don't add providers more than once Currently we load all search providers from XDG_DATA_DIRS, so if the same provider is installed several times in different directories, we happily show duplicate results. To fix, keep track of all remote providers we add and skip those that already have been loaded from a different directory. https://bugzilla.gnome.org/show_bug.cgi?id=682470 --- js/ui/remoteSearch.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js index bf391d24c..2004dc31b 100644 --- a/js/ui/remoteSearch.js +++ b/js/ui/remoteSearch.js @@ -34,16 +34,17 @@ var SearchProviderProxy = Gio.DBusProxy.makeProxyWrapper(SearchProviderIface); function loadRemoteSearchProviders(addProviderCallback) { let dataDirs = GLib.get_system_data_dirs(); + let loadedProviders = {}; for (let i = 0; i < dataDirs.length; i++) { let path = GLib.build_filenamev([dataDirs[i], 'gnome-shell', 'search-providers']); let dir = Gio.file_new_for_path(path); if (!dir.query_exists(null)) continue; - loadRemoteSearchProvidersFromDir(dir, addProviderCallback); + loadRemoteSearchProvidersFromDir(dir, loadedProviders, addProviderCallback); } }; -function loadRemoteSearchProvidersFromDir(dir, addProviderCallback) { +function loadRemoteSearchProvidersFromDir(dir, loadedProviders, addProviderCallback) { let dirPath = dir.get_path(); FileUtils.listDirAsync(dir, Lang.bind(this, function(files) { for (let i = 0; i < files.length; i++) { @@ -65,6 +66,9 @@ function loadRemoteSearchProvidersFromDir(dir, addProviderCallback) { let busName = keyfile.get_string(group, 'BusName'); let objectPath = keyfile.get_string(group, 'ObjectPath'); + if (loadedProviders[objectPath]) + continue; + let appInfo = null; try { let desktopId = keyfile.get_string(group, 'DesktopId'); @@ -86,6 +90,7 @@ function loadRemoteSearchProvidersFromDir(dir, addProviderCallback) { icon, busName, objectPath); + loadedProviders[objectPath] = remoteProvider; } catch(e) { log('Failed to add search provider "%s": %s'.format(title, e.toString())); continue;