Fix E_ACCESSDENIED during download if temp is hidden#40708
Fix E_ACCESSDENIED during download if temp is hidden#40708chemwolf6922 wants to merge 10 commits into
Conversation
…ownloading-to-hidden-temp
There was a problem hiding this comment.
Pull request overview
This PR addresses E_ACCESSDENIED failures during wsl --update / wsl --install downloads when the user’s temp directory has the Hidden/System attributes set, by switching WinRT file operations to a newly-created temp subfolder with those attributes cleared.
Changes:
- Refactors the existing modern distro install unit test logic into a helper so it can be reused by multiple test cases.
- Adds a new unit test that exercises modern distro installation when the temp folder is hidden.
- Updates the WinRT download path selection to use a
wsl-downloadssubfolder under%TEMP%, explicitly clearing Hidden/System attributes before callingStorageFolder::GetFolderFromPathAsync.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/windows/UnitTests.cpp | Refactors the ModernDistroInstall test and adds a regression test for hidden temp folders. |
| src/windows/common/wslutil.cpp | Routes WinRT-based downloads through a temp subfolder with Hidden/System attributes cleared. |
benhillis
left a comment
There was a problem hiding this comment.
Looks good maybe just drop the set when it is not needed.
…ownloading-to-hidden-temp
…ownloading-to-hidden-temp
OneBlue
left a comment
There was a problem hiding this comment.
Thank you for doing this !
This is a really weird winrt behavior, but looks like there's no way to disable the attribute check, so let's just work around it.
The current implementation works, but in its current form, we'll always leak the "wsl-downloads folder, and adding logic to delete it would be a bit painful.
Instead I would recommend constructing the path ourselves and then using CreateRandomAccessStreamOnFile , which should allow us to open the file directly without the folder attribute issue.
Or even better, we could directly use this, that way we can set |
OneBlue
left a comment
There was a problem hiding this comment.
LGTM, couple minor comments
Summary of the Pull Request
The
winrt::Windows::Storage::StorageFolder::GetFolderFromPathAsyncfunction does not accept folders with hidden or system attributes. To solve that, this PR avoids the GetFolderFromPathAsync call and opens the file stream directly.PR Checklist
wsl --updateto update WSL, nor usewsl --installto install a Linux distribution #40662Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
Add test UnitTests::UnitTests::DownloadToHiddenSystemTempFolder