Skip to content

Fix E_ACCESSDENIED during download if temp is hidden#40708

Open
chemwolf6922 wants to merge 10 commits into
masterfrom
user/chemwolf6922/fix-access-denied-when-downloading-to-hidden-temp
Open

Fix E_ACCESSDENIED during download if temp is hidden#40708
chemwolf6922 wants to merge 10 commits into
masterfrom
user/chemwolf6922/fix-access-denied-when-downloading-to-hidden-temp

Conversation

@chemwolf6922

@chemwolf6922 chemwolf6922 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

The winrt::Windows::Storage::StorageFolder::GetFolderFromPathAsync function 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

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Add test UnitTests::UnitTests::DownloadToHiddenSystemTempFolder

Copilot AI review requested due to automatic review settings June 4, 2026 07:46
@chemwolf6922 chemwolf6922 marked this pull request as ready for review June 4, 2026 07:46
@chemwolf6922 chemwolf6922 requested a review from a team as a code owner June 4, 2026 07:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-downloads subfolder under %TEMP%, explicitly clearing Hidden/System attributes before calling StorageFolder::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.

Comment thread test/windows/UnitTests.cpp Outdated
Copilot AI review requested due to automatic review settings June 4, 2026 08:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread test/windows/UnitTests.cpp Outdated
Comment thread test/windows/UnitTests.cpp Outdated
Comment thread src/windows/common/wslutil.cpp Outdated

@benhillis benhillis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good maybe just drop the set when it is not needed.

Copilot AI review requested due to automatic review settings June 5, 2026 02:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/windows/common/wslutil.cpp Outdated

@OneBlue OneBlue left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@OneBlue

OneBlue commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

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 openDisposition and create the file ourselves

Copilot AI review requested due to automatic review settings June 11, 2026 07:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/windows/common/wslutil.cpp Outdated
Comment thread src/windows/common/wslutil.cpp

@OneBlue OneBlue left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, couple minor comments

Comment thread test/windows/Common.cpp Outdated
Comment thread test/windows/UnitTests.cpp Outdated
Comment thread src/windows/common/wslutil.cpp Outdated
Comment thread test/windows/UnitTests.cpp Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants