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

Write project file atomically #250

Merged
merged 1 commit into from
Feb 26, 2018
Merged

Write project file atomically #250

merged 1 commit into from
Feb 26, 2018

Conversation

yonaskolb
Copy link
Owner

Resolves #235

This:

  • copies the project file to a temporary directory (if it exists)
  • writes into that temporary project
  • deletes the original
  • copies that project back to the original

@yonaskolb yonaskolb mentioned this pull request Feb 26, 2018
try project.write(path: tempPath, override: true)
try? projectFile.delete()
try tempPath.copy(projectFile)
try? tempPath.delete()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should trap signals to ensure deletion, but it's under tmp dir anyways, so I guess we can leave it as future TODO.

@yonaskolb yonaskolb merged commit 232a203 into master Feb 26, 2018
@yonaskolb yonaskolb deleted the atomic_writing branch March 20, 2018 01:38
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.

None yet

2 participants