Skip to content

Commit 3b90a55

Browse files
authored
Clean fs resources in the background (#9823)
For #9800 #9800 (comment) When we've detected that a directory is r/w, we can delete the temp file in the background without blocking the call to check if dir is readonly.
1 parent efd7782 commit 3b90a55

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/client/common/platform/fileSystem.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as glob from 'glob';
88
import { injectable } from 'inversify';
99
import { promisify } from 'util';
1010
import * as vscode from 'vscode';
11+
import '../../common/extensions';
1112
import { createDeferred } from '../utils/async';
1213
import { isFileNotFoundError, isNoPermissionsError } from './errors';
1314
import { FileSystemPaths, FileSystemPathUtils } from './fs-paths';
@@ -460,14 +461,16 @@ export class FileSystem implements IFileSystem {
460461
let fd: number;
461462
try {
462463
fd = await fs.open(filePath, flags);
464+
// Clean resources in the background.
465+
fs.close(fd)
466+
.finally(() => fs.unlink(filePath))
467+
.ignoreErrors();
463468
} catch (err) {
464469
if (isNoPermissionsError(err)) {
465470
return true;
466471
}
467472
throw err; // re-throw
468473
}
469-
await fs.close(fd);
470-
await fs.unlink(filePath);
471474
return false;
472475
}
473476
}

0 commit comments

Comments
 (0)