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) {
|
function loadRemoteSearchProviders(addProviderCallback) {
|
||||||
let dataDirs = GLib.get_system_data_dirs();
|
let dataDirs = GLib.get_system_data_dirs();
|
||||||
|
let loadedProviders = {};
|
||||||
for (let i = 0; i < dataDirs.length; i++) {
|
for (let i = 0; i < dataDirs.length; i++) {
|
||||||
let path = GLib.build_filenamev([dataDirs[i], 'gnome-shell', 'search-providers']);
|
let path = GLib.build_filenamev([dataDirs[i], 'gnome-shell', 'search-providers']);
|
||||||
let dir = Gio.file_new_for_path(path);
|
let dir = Gio.file_new_for_path(path);
|
||||||
if (!dir.query_exists(null))
|
if (!dir.query_exists(null))
|
||||||
continue;
|
continue;
|
||||||
loadRemoteSearchProvidersFromDir(dir, addProviderCallback);
|
loadRemoteSearchProvidersFromDir(dir, loadedProviders, addProviderCallback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadRemoteSearchProvidersFromDir(dir, addProviderCallback) {
|
function loadRemoteSearchProvidersFromDir(dir, loadedProviders, addProviderCallback) {
|
||||||
let dirPath = dir.get_path();
|
let dirPath = dir.get_path();
|
||||||
FileUtils.listDirAsync(dir, Lang.bind(this, function(files) {
|
FileUtils.listDirAsync(dir, Lang.bind(this, function(files) {
|
||||||
for (let i = 0; i < files.length; i++) {
|
for (let i = 0; i < files.length; i++) {
|
||||||
@ -65,6 +66,9 @@ function loadRemoteSearchProvidersFromDir(dir, addProviderCallback) {
|
|||||||
let busName = keyfile.get_string(group, 'BusName');
|
let busName = keyfile.get_string(group, 'BusName');
|
||||||
let objectPath = keyfile.get_string(group, 'ObjectPath');
|
let objectPath = keyfile.get_string(group, 'ObjectPath');
|
||||||
|
|
||||||
|
if (loadedProviders[objectPath])
|
||||||
|
continue;
|
||||||
|
|
||||||
let appInfo = null;
|
let appInfo = null;
|
||||||
try {
|
try {
|
||||||
let desktopId = keyfile.get_string(group, 'DesktopId');
|
let desktopId = keyfile.get_string(group, 'DesktopId');
|
||||||
@ -86,6 +90,7 @@ function loadRemoteSearchProvidersFromDir(dir, addProviderCallback) {
|
|||||||
icon,
|
icon,
|
||||||
busName,
|
busName,
|
||||||
objectPath);
|
objectPath);
|
||||||
|
loadedProviders[objectPath] = remoteProvider;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
log('Failed to add search provider "%s": %s'.format(title, e.toString()));
|
log('Failed to add search provider "%s": %s'.format(title, e.toString()));
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user