Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't set FILE_ATTRIBUTE_HIDDEN #76

Merged
merged 1 commit into from
Dec 28, 2018
Merged

Don't set FILE_ATTRIBUTE_HIDDEN #76

merged 1 commit into from
Dec 28, 2018

Conversation

jasonwhite
Copy link
Contributor

If this attribute is set, we cannot close and reopen the file and then
write to it. Attempting to open the file a second time in write mode
results in ERROR_ACCESS_DENIED.

For reference, see the CreateFile MSDN docs:

If CREATE_ALWAYS and FILE_ATTRIBUTE_NORMAL are specified, CreateFile
fails and sets the last error to ERROR_ACCESS_DENIED if the file
exists and has the FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_SYSTEM
attribute. To avoid the error, specify the same attributes as the
existing file.

Fixes #69.
Fixes #66.
Alternative to #67.

@jasonwhite
Copy link
Contributor Author

jasonwhite commented Dec 28, 2018

The CI builds are failing due to Error::cause being deprecated in nightly -- a problem not related to this PR.

Edit: I made separate a fix for that in PR #77.

If this attribute is set, we cannot close and reopen the file and then
write to it. Attempting to open the file a second time in write mode
results in `ERROR_ACCESS_DENIED`.

For reference, see the CreateFile MSDN docs:

    If CREATE_ALWAYS and FILE_ATTRIBUTE_NORMAL are specified, CreateFile
    fails and sets the last error to ERROR_ACCESS_DENIED if the file
    exists and has the FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_SYSTEM
    attribute. To avoid the error, specify the same attributes as the
    existing file.
@bolinfest
Copy link

@jasonwhite Thanks so much for fixing this! @Stebalien any chance we could get a 3.0.6 release with this fix?

@Stebalien
Copy link
Owner

@bolinfest done.

@bolinfest
Copy link

@Stebalien thanks for the fast work: this fixes what was a frustrating issue for us!

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.

permissions error with NamedTempFile on Windows 10 Allow to create non hidden temporary files (on Windows)
3 participants