Skip to content

Commit c29a589

Browse files
committed
bake timeout into the fs module
1 parent 0f92bfe commit c29a589

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

packages/core/src/shared/credentials/userCredentialsUtils.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import { fileExists } from '../filesystemUtilities'
99
import { isNonNullable } from '../utilities/tsUtils'
1010
import { getConfigFilename, getCredentialsFilename } from '../../auth/credentials/sharedCredentialsFile'
1111
import { fs } from '../../shared/fs/fs'
12-
import { waitUntil } from '../utilities/timeoutUtils'
13-
import { isWin } from '../vscode/env'
1412

1513
const header = `
1614
# AWS credentials file used by AWS CLI, SDKs, and tools.
@@ -100,9 +98,5 @@ export class UserCredentialsUtils {
10098
}
10199

102100
await fs.writeFile(dest, contents.join('\n'))
103-
// Windows Race condition with writing files.
104-
if (isWin()) {
105-
await waitUntil(() => fs.exists(dest), { timeout: 5000, interval: 100 })
106-
}
107101
}
108102
}

packages/core/src/shared/fs/fs.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ export class FileSystem {
304304
}
305305

306306
await write(uri)
307+
if (isWin()) {
308+
await waitUntil(async () => await fs.exists(uri), { timeout: 5000, truthy: true })
309+
}
307310
}
308311

309312
/**
@@ -428,7 +431,7 @@ export class FileSystem {
428431
})
429432
}
430433

431-
return vfs.delete(uri, opt).then(undefined, async (err) => {
434+
vfs.delete(uri, opt).then(undefined, async (err) => {
432435
const notFound = isFileNotFoundError(err)
433436

434437
if (notFound && opt.force) {
@@ -461,6 +464,11 @@ export class FileSystem {
461464

462465
throw err
463466
})
467+
468+
// Windows race condition
469+
if (isWin()) {
470+
await waitUntil(async () => !(await fs.exists(fileOrDir)), { timeout: 5000, truthy: true })
471+
}
464472
}
465473

466474
async readdir(uri: vscode.Uri | string): Promise<[string, vscode.FileType][]> {

0 commit comments

Comments
 (0)