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

provide download location to download method

上级 a8842026
......@@ -151,7 +151,7 @@ export interface IExtensionGalleryService {
isEnabled(): boolean;
query(token: CancellationToken): Promise<IPager<IGalleryExtension>>;
query(options: IQueryOptions, token: CancellationToken): Promise<IPager<IGalleryExtension>>;
download(extension: IGalleryExtension, operation: InstallOperation): Promise<string>;
download(extension: IGalleryExtension, location: URI, operation: InstallOperation): Promise<URI>;
reportStatistic(publisher: string, name: string, version: string, type: StatisticType): Promise<void>;
getReadme(extension: IGalleryExtension, token: CancellationToken): Promise<string>;
getManifest(extension: IGalleryExtension, token: CancellationToken): Promise<IExtensionManifest | null>;
......
......@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { tmpdir } from 'os';
import * as path from 'vs/base/common/path';
import { getErrorMessage, isPromiseCanceledError, canceled } from 'vs/base/common/errors';
import { StatisticType, IGalleryExtension, IExtensionGalleryService, IGalleryExtensionAsset, IQueryOptions, SortBy, SortOrder, IExtensionIdentifier, IReportedExtension, InstallOperation, ITranslation, IGalleryExtensionVersion, IGalleryExtensionAssets, isIExtensionIdentifier } from 'vs/platform/extensionManagement/common/extensionManagement';
......@@ -24,6 +23,7 @@ import { ILogService } from 'vs/platform/log/common/log';
import { IExtensionManifest } from 'vs/platform/extensions/common/extensions';
import { IFileService } from 'vs/platform/files/common/files';
import { URI } from 'vs/base/common/uri';
import { joinPath } from 'vs/base/common/resources';
interface IRawGalleryExtensionFile {
assetType: string;
......@@ -535,9 +535,9 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
});
}
download(extension: IGalleryExtension, operation: InstallOperation): Promise<string> {
download(extension: IGalleryExtension, location: URI, operation: InstallOperation): Promise<URI> {
this.logService.trace('ExtensionGalleryService#download', extension.identifier.id);
const zipPath = path.join(tmpdir(), generateUuid());
const zip = joinPath(location, generateUuid());
const data = getGalleryExtensionTelemetryData(extension);
const startTime = new Date().getTime();
/* __GDPR__
......@@ -557,9 +557,9 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
} : extension.assets.download;
return this.getAsset(downloadAsset)
.then(context => this.fileService.writeFile(URI.file(zipPath), context.stream))
.then(context => this.fileService.writeFile(zip, context.stream))
.then(() => log(new Date().getTime() - startTime))
.then(() => zipPath);
.then(() => zip);
}
getReadme(extension: IGalleryExtension, token: CancellationToken): Promise<string> {
......
......@@ -391,9 +391,10 @@ export class ExtensionManagementService extends Disposable implements IExtension
};
this.logService.trace('Started downloading extension:', extension.identifier.id);
return this.galleryService.download(extension, operation)
return this.galleryService.download(extension, URI.file(tmpdir()), operation)
.then(
zipPath => {
zip => {
const zipPath = zip.fsPath;
this.logService.info('Downloaded extension:', extension.identifier.id, zipPath);
return getManifest(zipPath)
.then(
......
......@@ -75,7 +75,7 @@ export class SimpleExtensionGalleryService implements IExtensionGalleryService {
return Promise.resolve(undefined);
}
download(extension: IGalleryExtension, operation: InstallOperation): Promise<string> {
download(extension: IGalleryExtension, location: URI, operation: InstallOperation): Promise<URI> {
// @ts-ignore
return Promise.resolve(undefined);
}
......
......@@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { tmpdir } from 'os';
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import { IExtensionManagementService, ILocalExtension, IGalleryExtension, IExtensionGalleryService, InstallOperation } from 'vs/platform/extensionManagement/common/extensionManagement';
import { URI } from 'vs/base/common/uri';
......@@ -79,8 +80,8 @@ export class RemoteExtensionManagementChannelClient extends ExtensionManagementC
}
private async downloadAndInstall(extension: IGalleryExtension, installed: ILocalExtension[]): Promise<ILocalExtension> {
const location = await this.galleryService.download(extension, installed.filter(i => areSameExtensions(i.identifier, extension.identifier))[0] ? InstallOperation.Update : InstallOperation.Install);
return super.install(URI.file(location));
const location = await this.galleryService.download(extension, URI.file(tmpdir()), installed.filter(i => areSameExtensions(i.identifier, extension.identifier))[0] ? InstallOperation.Update : InstallOperation.Install);
return super.install(location);
}
private async installUIDependenciesAndPackedExtensions(local: ILocalExtension): Promise<void> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册