File tree Expand file tree Collapse file tree 3 files changed +16
-13
lines changed
Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff line change @@ -7,9 +7,9 @@ import * as fse from 'fs-extra';
77
88export 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 }
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments