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

change writing strategy to avoid partial writes when interrupted #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

scottwalters
Copy link
Member

File writing was so delicate and careful that I hate to touch it, but there's only
one way to replace a file in an atomic fashion on Unix that I know of.

Twice now I've observed corrupted config files apparently resulting from the program being interrupted part way through re-writing the file. This changes strategy to use an atomic operation to replace the config file with a rename() after it is completely written.

… there's only

one way to replace a file in an atomic fashion on Unix that I know of.
@haarg
Copy link
Member

haarg commented Jun 29, 2011

The primary reason the existing implementation was chosen was to prevent the possibility of changing the file permissions or ownership. It might make sense to have the code attempt to preserve file ownership where possible.

Other than that I think this is a much better way to go.

@jalcine
Copy link

jalcine commented Jan 30, 2013

👍

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.

3 participants