-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
WriteFile occassionaly truncates files entirely #137
Comments
What's frustrating is that this isn't the case all the time, so it does work for a good percentage, so there is some kind of weird race condition that is causing it not to work. I am not running any of these calls in parallel, so I am pretty sure it's how the file is handled in |
I'm not sure it's safe to write to a file at the same time as reading from it—or rather, it's safe, but might give you puzzling results, as you've experienced. The reads and writes will be buffered, which means the bits don't necessarily show up on disk when you expect them to. |
I was thinking that, too. I thought maybe the |
I've encountered the same issue as well. Filters run concurrently as stated in the readme, and it doesn't look like there is an option to enforce consecutive execution. I was trying to do the exact same thing as you @klauern and I solved it the same way too. |
Another option that avoids reading the whole file into memory would be to pipe it to a temporary file, and then once the pipe has completed, rename the temporary file to the original file. |
I am trying to write a simple
sed -i
script using this, but it seems that when I run it on the same path that I am reading it from, occasionally the file is completely truncated instead of written with the piped changes.I can make this work by pulling the write operation out of the pipe:
The text was updated successfully, but these errors were encountered: