#5274 fix "cef_cache" subfolder not being cleared on exFAT filesystem (FS:TJ cherry-pick to fix FIRE-36357)

This fixes FAT32 filesystem too and anything using LLFile::isdir such as the Firestorm Backup & Restore
This commit is contained in:
Maxim Nikolenko
2026-02-11 04:36:25 +10:00
committed by Hecklezz
parent efb8847d8d
commit f373f30a02
+27 -6
View File
@@ -187,13 +187,34 @@ static unsigned short get_fileattr(const std::wstring& utf16path, bool dontFollo
CloseHandle(file_handle);
return st_mode;
}
}
// Retrieve last error and set errno before calling CloseHandle()
set_errno_from_oserror(GetLastError());
if (file_handle != INVALID_HANDLE_VALUE)
{
// Retrieve last error before calling CloseHandle()
DWORD last_error = GetLastError();
CloseHandle(file_handle);
set_errno_from_oserror(last_error);
}
else
{
set_errno_from_oserror(GetLastError());
}
// If CreateFileW approach failed (e.g., exFAT), try the simpler GetFileAttributesW()
// GetFileAttributesW() always follows symlinks, so we skip this fallback when dontFollowSymLink is true.
if (!dontFollowSymLink)
{
DWORD attributes = GetFileAttributesW(utf16path.c_str());
if (attributes != INVALID_FILE_ATTRIBUTES)
{
bool is_directory = (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
unsigned short st_mode = is_directory ? S_IFDIR : S_IFREG;
st_mode |= (attributes & FILE_ATTRIBUTE_READONLY) ? S_IREAD : S_IREAD | S_IWRITE;
// propagate user bits to group/other fields:
st_mode |= (st_mode & 0700) >> 3;
st_mode |= (st_mode & 0700) >> 6;
return st_mode;
}
set_errno_from_oserror(GetLastError());
}
return 0;
}