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

Handle errors when saving files gracefully #120

Merged

Conversation

SpotlightKid
Copy link
Contributor

Fixes #118.

  • Prevent existing files from being wiped when writing fails
  • Backup previous file if it exists when writing succeeds

To fix test failures with python 2.7 I had to change the imports at the top of the tests so that the test under Python 2.7 always use StringIO.StringIO instead of io.StringIO. The latter doesn't cooperate with json.dump under Python 2.7.

from StringIO import StringIO
except ImportError:
from io import StringIO
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍, io.StringIO doesn't have the right behavior in Python 2.7. This is very confusing.

@SpotlightKid SpotlightKid force-pushed the feature/save-with-backup branch 2 times, most recently from 15e1554 to 9fac51a Compare July 31, 2016 22:30
Fixes jazzband#118.

* Prevent existing files from being wiped when writing fails
* Backup previous file if it exists when writing succeeds

Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
@SpotlightKid SpotlightKid force-pushed the feature/save-with-backup branch from 9fac51a to 2d52135 Compare July 31, 2016 23:05
@SpotlightKid SpotlightKid merged commit 7311271 into jazzband:master Aug 1, 2016
@SpotlightKid SpotlightKid deleted the feature/save-with-backup branch August 1, 2016 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make backup before writing to prevent possible loss of frames file
3 participants