Skip to content

Commit

Permalink
Fix #99674
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jun 11, 2020
1 parent 5cdc320 commit 99a0740
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
11 changes: 8 additions & 3 deletions src/vs/platform/environment/node/environmentService.ts
Expand Up @@ -36,7 +36,7 @@ export interface INativeEnvironmentService extends IEnvironmentService {
installSourcePath: string;

extensionsPath?: string;
extensionsDownloadPath?: string;
extensionsDownloadPath: string;
builtinExtensionsPath: string;

globalStorageHome: string;
Expand Down Expand Up @@ -151,8 +151,13 @@ export class EnvironmentService implements INativeEnvironmentService {
}
}

get extensionsDownloadPath(): string | undefined {
return parsePathArg(this._args['extensions-download-dir'], process);
get extensionsDownloadPath(): string {
const fromArgs = parsePathArg(this._args['extensions-download-dir'], process);
if (fromArgs) {
return fromArgs;
} else {
return path.join(this.userDataPath, 'CachedExtensionVSIXs');
}
}

@memoize
Expand Down
20 changes: 7 additions & 13 deletions src/vs/platform/extensionManagement/node/extensionDownloader.ts
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { tmpdir } from 'os';
import { Disposable } from 'vs/base/common/lifecycle';
import { IFileService, IFileStatWithMetadata } from 'vs/platform/files/common/files';
import { IExtensionGalleryService, IGalleryExtension, InstallOperation } from 'vs/platform/extensionManagement/common/extensionManagement';
Expand All @@ -20,9 +19,9 @@ const ExtensionIdVersionRegex = /^([^.]+\..+)-(\d+\.\d+\.\d+)$/;

export class ExtensionsDownloader extends Disposable {

private readonly extensionsDownloadDir: URI = URI.file(tmpdir());
private readonly cache: number = 0;
private readonly cleanUpPromise: Promise<void> = Promise.resolve();
private readonly extensionsDownloadDir: URI;
private readonly cache: number;
private readonly cleanUpPromise: Promise<void>;

constructor(
@IEnvironmentService environmentService: INativeEnvironmentService,
Expand All @@ -31,11 +30,9 @@ export class ExtensionsDownloader extends Disposable {
@ILogService private readonly logService: ILogService,
) {
super();
if (environmentService.extensionsDownloadPath) {
this.extensionsDownloadDir = URI.file(environmentService.extensionsDownloadPath);
this.cache = 20; // Cache 20 downloads
this.cleanUpPromise = this.cleanUp();
}
this.extensionsDownloadDir = URI.file(environmentService.extensionsDownloadPath);
this.cache = 20; // Cache 20 downloads
this.cleanUpPromise = this.cleanUp();
}

async downloadExtension(extension: IGalleryExtension, operation: InstallOperation): Promise<URI> {
Expand All @@ -46,10 +43,7 @@ export class ExtensionsDownloader extends Disposable {
}

async delete(location: URI): Promise<void> {
// Delete immediately if caching is disabled
if (!this.cache) {
await this.fileService.del(location);
}
// noop as caching is enabled always
}

private async download(extension: IGalleryExtension, location: URI, operation: InstallOperation): Promise<void> {
Expand Down

0 comments on commit 99a0740

Please sign in to comment.