Skip to content

Commit

Permalink
fix ext installation from vsix files
Browse files Browse the repository at this point in the history
  • Loading branch information
akosyakov committed Aug 30, 2021
1 parent a0bc2b8 commit 10009f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,8 @@ abstract class AbstractInstallExtensionTask extends AbstractExtensionTask<ILocal
}

private async extract({ zipPath, identifierWithVersion, metadata }: InstallableExtension, token: CancellationToken): Promise<ILocalExtension> {
let local = await this.extensionsScanner.extractUserExtension(identifierWithVersion, zipPath, token);
let local = await this.extensionsScanner.extractUserExtension(identifierWithVersion, zipPath, metadata, token);
this.logService.info('Extracting completed.', identifierWithVersion.id);
if (metadata) {
local = await this.extensionsScanner.saveMetadataForLocalExtension(local, metadata);
}
return local;
}

Expand Down Expand Up @@ -320,10 +317,10 @@ class InstallVSIXTask extends AbstractInstallExtensionTask {
const installedExtensions = await this.extensionsScanner.scanExtensions(ExtensionType.User);
const existing = installedExtensions.find(i => areSameExtensions(this.identifier, i.identifier));
const metadata = await this.getMetadata(this.identifier.id, token);
metadata.isMachineScoped = this.options.isMachineScoped || existing?.isMachineScoped;
metadata.isBuiltin = this.options.isBuiltin || existing?.isBuiltin;

if (existing) {
metadata.isMachineScoped = this.options.isMachineScoped || existing.isMachineScoped;
metadata.isBuiltin = this.options.isBuiltin || existing.isBuiltin;
this._operation = InstallOperation.Update;
if (identifierWithVersion.equals(new ExtensionIdentifierWithVersion(existing.identifier, existing.manifest.version))) {
try {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/extensionManagement/node/extensionsScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class ExtensionsScanner extends Disposable {
return this.scanExtensionsInDir(this.extensionsPath, ExtensionType.User);
}

async extractUserExtension(identifierWithVersion: ExtensionIdentifierWithVersion, zipPath: string, token: CancellationToken): Promise<ILocalExtension> {
async extractUserExtension(identifierWithVersion: ExtensionIdentifierWithVersion, zipPath: string, metadata: IMetadata | undefined, token: CancellationToken): Promise<ILocalExtension> {
const folderName = identifierWithVersion.key();
const tempPath = path.join(this.extensionsPath, `.${generateUuid()}`);
const extensionPath = path.join(this.extensionsPath, folderName);
Expand All @@ -119,7 +119,7 @@ export class ExtensionsScanner extends Disposable {
if (!local) {
throw new Error(localize('cannot read', "Cannot read the extension from {0}", tempPath));
}
await this.storeMetadata(local, { installedTimestamp: Date.now() });
await this.storeMetadata(local, { ...metadata, installedTimestamp: Date.now() });

try {
await this.rename(identifierWithVersion, tempPath, extensionPath, Date.now() + (2 * 60 * 1000) /* Retry for 2 minutes */);
Expand Down

0 comments on commit 10009f5

Please sign in to comment.