Skip to content

Commit 9deffdc

Browse files
authored
Merge pull request #1334 from nagilson/nagilson-file-overrides
Version 1.7.3 - Introduce File Locking for Install Script
2 parents 276721b + 165be29 commit 9deffdc

22 files changed

+315
-38
lines changed

sample/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@
12771277

12781278
"vscode-dotnet-runtime@file:../vscode-dotnet-runtime-extension":
12791279
"resolved" "file:../vscode-dotnet-runtime-extension"
1280-
"version" "1.7.2"
1280+
"version" "1.7.3"
12811281
dependencies:
12821282
"axios" "^1.3.4"
12831283
"axios-cache-interceptor" "^1.0.1"

vscode-dotnet-runtime-extension/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning].
77

88
## [Unreleased]
99

10+
## [1.7.3] - 2023-08-24
11+
12+
Fixes an issue where install script files could have race conditions by introducing file locking mechanisms.
13+
1014
## [1.7.2] - 2023-08-24
1115

1216
This release completely revamps the web request handling to a new library (axios).

vscode-dotnet-runtime-extension/package-lock.json

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vscode-dotnet-runtime-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"description": "This extension installs and manages different versions of the .NET Runtime.",
1414
"appInsightsKey": "02dc18e0-7494-43b2-b2a3-18ada5fcb522",
1515
"icon": "images/dotnetIcon.png",
16-
"version": "1.7.2",
16+
"version": "1.7.3",
1717
"publisher": "ms-dotnettools",
1818
"engines": {
1919
"vscode": "^1.72.0"

vscode-dotnet-runtime-extension/src/extension.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,23 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
9898
if (!fs.existsSync(context.globalStoragePath)) {
9999
fs.mkdirSync(context.globalStoragePath);
100100
}
101-
const finalTimeoutValue = timeoutValue === undefined ? defaultTimeoutValue : timeoutValue;
101+
const resolvedTimeoutSeconds = timeoutValue === undefined ? defaultTimeoutValue : timeoutValue;
102102

103103
const acquisitionWorker = new DotnetCoreAcquisitionWorker({
104104
storagePath: context.globalStoragePath,
105105
extensionState: context.globalState,
106106
eventStream,
107-
acquisitionInvoker: new AcquisitionInvoker(context.globalState, eventStream, finalTimeoutValue),
107+
acquisitionInvoker: new AcquisitionInvoker(context.globalState, eventStream, resolvedTimeoutSeconds),
108108
installationValidator: new InstallationValidator(eventStream),
109-
timeoutValue: finalTimeoutValue,
109+
timeoutValue: resolvedTimeoutSeconds,
110110
installDirectoryProvider: new RuntimeInstallationDirectoryProvider(context.globalStoragePath),
111111
});
112112
const existingPathResolver = new ExistingPathResolver();
113-
const versionResolver = new VersionResolver(context.globalState, eventStream, finalTimeoutValue);
113+
const versionResolver = new VersionResolver(context.globalState, eventStream, resolvedTimeoutSeconds);
114114

115115
const dotnetAcquireRegistration = vscode.commands.registerCommand(`${commandPrefix}.${commandKeys.acquire}`, async (commandContext: IDotnetAcquireContext) => {
116116
const dotnetPath = await callWithErrorHandling<Promise<IDotnetAcquireResult>>(async () => {
117-
eventStream.post(new DotnetRuntimeAcquisitionStarted());
117+
eventStream.post(new DotnetRuntimeAcquisitionStarted(commandContext.requestingExtensionId));
118118
eventStream.post(new DotnetAcquisitionRequested(commandContext.version, commandContext.requestingExtensionId));
119119
acquisitionWorker.setAcquisitionContext(commandContext);
120120

vscode-dotnet-runtime-extension/src/test/functional/DotnetCoreAcquisitionExtension.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ suite('DotnetCoreAcquisitionExtension End to End', function() {
108108
const requestedEvent = MockTelemetryReporter.telemetryEvents.find((event: ITelemetryEvent) => event.eventName === 'DotnetAcquisitionRequested');
109109
assert.exists(requestedEvent);
110110
assert.include(requestedEvent!.properties!.AcquisitionStartVersion, '2.2');
111-
assert.include(requestedEvent!.properties!.RequestingExtensionId, requestingExtensionId);
111+
assert.notInclude(requestedEvent!.properties!.RequestingExtensionId, requestingExtensionId); // assert that the extension id is hashed
112112
const startedEvent = MockTelemetryReporter.telemetryEvents.find((event: ITelemetryEvent) => event.eventName === 'DotnetAcquisitionStarted');
113113
assert.exists(startedEvent);
114114
assert.include(startedEvent!.properties!.AcquisitionStartVersion, '2.2');

vscode-dotnet-runtime-extension/yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,6 +2544,7 @@
25442544
"mocha" "^9.1.3"
25452545
"open" "^8.4.0"
25462546
"p-retry" "^4.6.1"
2547+
"proper-lockfile" "^4.1.2"
25472548
"public-ip" "^5.0.0"
25482549
"rimraf" "3.0.2"
25492550
"shelljs" "0.8.5"

vscode-dotnet-runtime-library/package-lock.json

Lines changed: 70 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vscode-dotnet-runtime-library/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"devDependencies": {
2424
"@types/chai": "4.2.22",
25+
"@types/proper-lockfile": "^4.1.2",
2526
"glob": "^7.2.0"
2627
},
2728
"dependencies": {
@@ -47,6 +48,7 @@
4748
"mocha": "^9.1.3",
4849
"open": "^8.4.0",
4950
"p-retry": "^4.6.1",
51+
"proper-lockfile": "^4.1.2",
5052
"public-ip": "^5.0.0",
5153
"rimraf": "3.0.2",
5254
"shelljs": "0.8.5",

vscode-dotnet-runtime-library/src/Acquisition/AcquisitionInvoker.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { IAcquisitionInvoker } from './IAcquisitionInvoker';
2121
import { IDotnetInstallationContext } from './IDotnetInstallationContext';
2222
import { IInstallScriptAcquisitionWorker } from './IInstallScriptAcquisitionWorker';
2323
import { InstallScriptAcquisitionWorker } from './InstallScriptAcquisitionWorker';
24+
import { TelemetryUtilities } from '../EventStream/TelemetryUtilities';
2425

2526
export class AcquisitionInvoker extends IAcquisitionInvoker {
2627
private readonly scriptWorker: IInstallScriptAcquisitionWorker;
@@ -49,10 +50,10 @@ You will need to restart VS Code after these changes. If PowerShell is still not
4950
async (error, stdout, stderr) => {
5051
if (error) {
5152
if (stdout) {
52-
this.eventStream.post(new DotnetAcquisitionScriptOuput(installContext.version, stdout));
53+
this.eventStream.post(new DotnetAcquisitionScriptOuput(installContext.version, TelemetryUtilities.HashAllPaths(stdout)));
5354
}
5455
if (stderr) {
55-
this.eventStream.post(new DotnetAcquisitionScriptOuput(installContext.version, `STDERR: ${stderr}`));
56+
this.eventStream.post(new DotnetAcquisitionScriptOuput(installContext.version, `STDERR: ${TelemetryUtilities.HashAllPaths(stderr)}`));
5657
}
5758

5859
const online = await isOnline();
@@ -69,7 +70,7 @@ You will need to restart VS Code after these changes. If PowerShell is still not
6970
reject(error);
7071
}
7172
} else if (stderr && stderr.length > 0) {
72-
this.eventStream.post(new DotnetAcquisitionScriptError(new Error(stderr), installContext.version));
73+
this.eventStream.post(new DotnetAcquisitionScriptError(new Error(TelemetryUtilities.HashAllPaths(stderr)), installContext.version));
7374
reject(stderr);
7475
} else {
7576
this.eventStream.post(new DotnetAcquisitionCompleted(installContext.version, installContext.dotnetPath));
@@ -87,6 +88,7 @@ You will need to restart VS Code after these changes. If PowerShell is still not
8788
let args = [
8889
'-InstallDir', this.escapeFilePath(dotnetInstallDir),
8990
'-Version', version,
91+
'-Verbose'
9092
];
9193
if (installRuntime) {
9294
args = args.concat('-Runtime', 'dotnet');

vscode-dotnet-runtime-library/src/Acquisition/DotnetCoreAcquisitionWorker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class DotnetCoreAcquisitionWorker implements IDotnetCoreAcquisitionWorker
151151
timeoutValue: this.timeoutValue,
152152
installRuntime,
153153
} as IDotnetInstallationContext;
154-
this.context.eventStream.post(new DotnetAcquisitionStarted(version));
154+
this.context.eventStream.post(new DotnetAcquisitionStarted(version, this.context.acquisitionContext?.requestingExtensionId));
155155
await this.context.acquisitionInvoker.installDotnet(installContext).catch((reason) => {
156156
throw Error(`Installation failed: ${reason}`);
157157
});

0 commit comments

Comments
 (0)