提交 39020559 编写于 作者: S Sandeep Somavarapu

Gallery.loadDeps include self if it is a dep in hierarchy

上级 f7c37782
......@@ -390,8 +390,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
getAllDependencies(extension: IGalleryExtension): TPromise<IGalleryExtension[]> {
return this.loadCompatibleVersion(<IGalleryExtension>extension)
.then(compatible => this.getDependenciesReccursively(compatible.properties.dependencies, [extension]))
.then(dependencies => dependencies.slice(1));
.then(compatible => this.getDependenciesReccursively(compatible.properties.dependencies, [], extension));
}
loadCompatibleVersion(extension: IGalleryExtension): TPromise<IGalleryExtension> {
......@@ -445,10 +444,13 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
});
}
private getDependenciesReccursively(toGet: string[], result: IGalleryExtension[]): TPromise<IGalleryExtension[]> {
private getDependenciesReccursively(toGet: string[], result: IGalleryExtension[], root: IGalleryExtension): TPromise<IGalleryExtension[]> {
if (!toGet || !toGet.length) {
return TPromise.wrap(result);
}
if (toGet.indexOf(`${root.publisher}.${root.name}`) && result.indexOf(root) === -1) {
result.push(root);
}
toGet = result.length ? toGet.filter(e => !ExtensionGalleryService.hasExtensionByName(result, e)) : toGet;
if (!toGet.length) {
return TPromise.wrap(result);
......@@ -464,7 +466,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
}
result = distinct(result.concat(loadedDependencies), d => d.id);
const dependencies = dependenciesSet.elements.filter(d => !ExtensionGalleryService.hasExtensionByName(result, d));
return this.getDependenciesReccursively(dependencies, result);
return this.getDependenciesReccursively(dependencies, result, root);
});
}
......
......@@ -202,7 +202,7 @@ export class ExtensionManagementService implements IExtensionManagementService {
private installWithDependencies(extension: IGalleryExtension): TPromise<ILocalExtension> {
return this.galleryService.getAllDependencies(extension)
.then(allDependencies => this.filterOutInstalled(allDependencies))
.then(allDependencies => this.filterDependenciesToInstall(extension, allDependencies))
.then(toInstall => this.filterObsolete(...toInstall.map(i => getExtensionId(i, i.version)))
.then((obsolete) => {
if (obsolete.length) {
......@@ -248,11 +248,14 @@ export class ExtensionManagementService implements IExtensionManagementService {
.then(() => null);
}
private filterOutInstalled(extensions: IGalleryExtension[]): TPromise<IGalleryExtension[]> {
private filterDependenciesToInstall(extension: IGalleryExtension, dependencies: IGalleryExtension[]): TPromise<IGalleryExtension[]> {
return this.getInstalled()
.then(local => {
return extensions.filter(extension => {
const extensionId = getExtensionId(extension, extension.version);
return dependencies.filter(d => {
if (extension.id === d.id) {
return false;
}
const extensionId = getExtensionId(d, d.version);
return local.every(local => local.id !== extensionId);
});
});
......
......@@ -361,7 +361,6 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService {
.then(galleryExtensions => galleryExtensions.map(galleryExtension => this.fromGallery(galleryExtension)))
.then(extensions => {
const map = new Map<string, Extension>();
map.set(`${extension.publisher}.${extension.name}`, <Extension>extension);
for (const extension of extensions) {
map.set(`${extension.publisher}.${extension.name}`, extension);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册