-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
On Windows fs.writeFile deletes all alternate data streams #18549
Comments
CC @nodejs/platform-windows |
This behavior is consistent with both CRT and Python. Source.cpp
CRT
Python
So the behavior of the To preserve data in alternate streams, consider using the
|
Is this workaround effective in WSL land? Any Windows file editor (in my case and the case of a few others VS Code) resets the permissions back to 755 and chmod after saving isn't always practical or in some cases even possible. Since we now have the ability to preserve Linux permissions in Windows with build 17134+, we need a way to address this issue so we can maintain our permissions after saving a file. |
Does WSL store Linux permissions in alternate data streams? If not, then this issue is unrelated. |
@seishun This stuff is above my pay grade but I am a VSCode user plagued by this issue. I was Googling around to see how WSL saves its metadata and came across this blog post from Microsoft: https://blogs.msdn.microsoft.com/wsl/2016/06/15/wsl-file-system-support/. The blog post mentions "In addition, if a file has any file capabilities, these are stored in an alternate data stream for the file". Keep in mind that blog post is 2 years old. Since the latest stable Windows release, these metadata attributes can be modified by users. It sounds like they do use alternate data streams. |
Yes it does. See the referenced issue OP as well as the OP for microsoft/WSL#3165. There are actual repro steps in the WSL issue. |
And here's the blog to piggy back off the blog mentioned above that discusses the new behavior in Windows: https://blogs.msdn.microsoft.com/commandline/2018/01/12/chmod-chown-wsl-improvements/ |
If they are indeed stored in alternate data streams, then the workaround should work. |
What's the workaround and how would you apply it to VSCode Insiders that's installed today? |
The workaround mentioned above. But this is a workaround. Are there any plans to actually support alternate datastreams vice using a workaround? Workaround ≠ fix |
See #18549 (comment). It needs to be fixed on VS Code's side. I submitted a PR for that 3 months ago: microsoft/vscode#42899 |
Hmm I see. Wonder what caused it to fail. |
@seishun I have to say I'm thinking differently about that workaround now. The reason I opened this issue is not that I ended up writing an alternate I now think If (as a user of |
What I think might happen is deprecating the use of |
Ok but can I pass an option that uses "r+" and truncates the file? Consider the following code lines:
Right now, the only thing that decides the final result of the file is the order these commands are executed in. The behavior of writing the alternate streams differs from the one writing the main stream. That means it is inconsistent any way you look at it. Either it fails to keep the alternate streams when you write the main stream or it fails to wipe all other streams when you write one of the alternate streams. |
I just tried, Edit: And I have to take it back. The file or stream has to exist in order for "r+" to work. I leave it to you guys to decide what a sensible default would be on Windows. @seishun, thanks a lot for your feedback, I really appreciate it. |
When calling fs.writeFile to write to a file that has NTFS alternate data streams all the streams are deleted.
To reproduce, first create a file with alternate data streams (e.g. from the command line):
You can see the streams with
dir /r
.Then, write to the file:
Run
dir /r
to see if the data streams are still there.Expected: data streams are there, ready for reading
Observed: data streams are gone
Trackback to this issue.
The text was updated successfully, but these errors were encountered: