Remove exponential backoff from chdir()

This issue probably only impacted the earliest releases of Windows 7 and
we only support Windows 10+ these days, so it's not worth adding 2000 ms
of startup latency to vim when ~/.vim doesn't exist.
This commit is contained in:
Justine Tunney 2024-09-10 21:21:52 -07:00
parent 4d05060aac
commit deb5e07b5a
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2 changed files with 23 additions and 46 deletions

View file

@ -57,15 +57,14 @@ static textwindows bool IsDirectorySymlink(const char16_t *path) {
static textwindows int sys_rmdir_nt(const char16_t *path) {
int ms;
for (ms = 1;; ms *= 2) {
if (RemoveDirectory(path)) {
if (RemoveDirectory(path))
return 0;
}
// Files can linger, for absolutely no reason.
// Possibly some Windows Defender bug on Win7.
// Sleep for up to one second w/ expo backoff.
// Alternative is use Microsoft internal APIs.
// Never could have imagined it'd be this bad.
if (GetLastError() == kNtErrorDirNotEmpty && ms <= 2048) {
if (GetLastError() == kNtErrorDirNotEmpty && ms <= 1024) {
Sleep(ms);
continue;
} else {