Skip to content

Commit 7287cd4

Browse files
authored
Ensure debugger directory exists (#906)
* Ensure debugger directory exists. * Use ensureDir() instead of dirExists()/makeDir(). * Bump build.
1 parent 6d906ea commit 7287cd4

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

debugging/coreclr/appStorage.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ export class DefaultAppStorage implements MementoAsync {
3838
if (item) {
3939
const itemDir = path.dirname(itemPath);
4040

41-
if (!await this.fileSystemProvider.dirExists(itemDir)) {
42-
await this.fileSystemProvider.makeDir(itemDir);
43-
}
41+
await this.fileSystemProvider.ensureDir(itemDir);
4442

4543
await this.fileSystemProvider.writeFile(itemPath, JSON.stringify(item));
4644
} else {

debugging/coreclr/fsProvider.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import * as fse from 'fs-extra';
77

88
export interface FileSystemProvider {
99
dirExists(path: string): Promise<boolean>;
10+
ensureDir(path: string): Promise<void>;
1011
fileExists(path: string): Promise<boolean>;
1112
hashFile(path: string): Promise<string>;
12-
makeDir(path: string): Promise<void>;
1313
readDir(path: string): Promise<string[]>;
1414
readFile(filename: string, encoding?: string): Promise<string>;
1515
unlinkFile(filename: string): Promise<void>;
@@ -33,6 +33,10 @@ export class LocalFileSystemProvider implements FileSystemProvider {
3333
}
3434
}
3535

36+
public async ensureDir(path: string): Promise<void> {
37+
return await fse.ensureDir(path);
38+
}
39+
3640
public async fileExists(path: string): Promise<boolean> {
3741
try {
3842
const stats = await fse.stat(path);
@@ -58,10 +62,6 @@ export class LocalFileSystemProvider implements FileSystemProvider {
5862
return hash.digest('hex');
5963
}
6064

61-
public async makeDir(path: string): Promise<void> {
62-
return await fse.mkdir(path);
63-
}
64-
6565
public async readDir(path: string): Promise<string[]> {
6666
return await fse.readdir(path);
6767
}

debugging/coreclr/vsdbgClient.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ export class RemoteVsDbgClient implements VsDbgClient {
5959
}
6060

6161
public async getVsDbgFolder(): Promise<string> {
62+
// NOTE: If non-existant, other processes (e.g. Docker when volume mounting) may attempt to create this folder.
63+
// This can lead to "access denied" if those processes run elevated compared to VS Code.
64+
// Therefore, ensure it's created before they're ever given the folder name.
65+
await this.ensureVsDbgFolderExists();
66+
6267
return this.vsdbgPath;
6368
}
6469

@@ -92,6 +97,10 @@ export class RemoteVsDbgClient implements VsDbgClient {
9297
'Unable to acquire the .NET Core debugger.');
9398
}
9499

100+
private async ensureVsDbgFolderExists(): Promise<void> {
101+
await this.fileSystemProvider.ensureDir(this.vsdbgPath);
102+
}
103+
95104
private async getVsDbgAcquisitionScript(): Promise<void> {
96105
const vsdbgAcquisitionScriptPath = path.join(this.vsdbgPath, this.options.name);
97106
const acquisitionScriptExists = await this.fileSystemProvider.fileExists(vsdbgAcquisitionScriptPath);
@@ -101,11 +110,7 @@ export class RemoteVsDbgClient implements VsDbgClient {
101110
return;
102111
}
103112

104-
const directoryExists = await this.fileSystemProvider.dirExists(this.vsdbgPath);
105-
106-
if (!directoryExists) {
107-
await this.fileSystemProvider.makeDir(this.vsdbgPath);
108-
}
113+
await this.ensureVsDbgFolderExists();
109114

110115
const script = await ext.request(this.options.url);
111116

0 commit comments

Comments
 (0)