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
This commit is contained in:
parent
2154a22c90
commit
56dc2eb96e
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user