-
Notifications
You must be signed in to change notification settings - Fork 114
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
NamedTempFile cannot persist to another NamedTempFile on Windows #131
Comments
Yes, that's normal. On windows, you can't overwrite an open file
(persist t1 over t2). What's your use-case?
|
I literally just figured this out maybe a minute before you replied!
My application performs an atomic replacement of a file. My specific use-case for this issue was during my unit tests, where I create "fake" files with The issue was that I hadn't closed the |
I'm glad you found the issue. Windows... takes some getting used to (although, honestly, the extra control over file sharing between applications is actually kind of nice). |
…file On Windows, it seems that you can't rename a file if the target file is open (Stebalien/tempfile#131). I think that's the reason for our failing tests on Windows. This patch adds a simple wrapper around `NamedTempFile::persist()` that returns the existing file instead of failing, if there is one.
I have tests in my application which create temporary files, write to them, and then persist them. These tests fail on Windows with a Permission Denied error.
A small reproducible example is:
Is this the intended behaviour? I am unfamiliar with Windows development in general, and by the looks of the other issues here it seems permissions errors aren't exactly uncommon.
The text was updated successfully, but these errors were encountered: