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 store_path() to not clear on-disk file if serialization fails #48

Merged
merged 2 commits into from
Jun 25, 2021

Conversation

nyanpasu64
Copy link
Contributor

Partly resolves #47.

I think this would benefit from a unit test to ensure that a failed serialization doesn't overwrite the file.

src/lib.rs Show resolved Hide resolved
@nyanpasu64
Copy link
Contributor Author

I added a unit test ensuring that if you call store_path() with an object that fails to serialize, the file on disk will not be overwritten or truncated. I added the tempfile dev-dependency. Is this acceptable, or should I hard-code a path under std::env::temp_dir()?

@nyanpasu64 nyanpasu64 marked this pull request as ready for review June 24, 2021 03:57
Copy link
Member

@matthiasbeyer matthiasbeyer left a comment

Choose a reason for hiding this comment

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

Besides this one small remark, I like the changeset here! 🎉

src/lib.rs Outdated Show resolved Hide resolved
@nyanpasu64
Copy link
Contributor Author

The review still says it's waiting for changes even though I resolved the conversation. Should this be merged or edited or not?

@matthiasbeyer matthiasbeyer merged commit 664992a into rust-cli:master Jun 25, 2021
@matthiasbeyer
Copy link
Member

🎉 thanks for your contribution! 😄

@nyanpasu64 nyanpasu64 deleted the dont-truncate-if-err branch June 25, 2021 15:47
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.

Doesn't atomically save to file, resulting in possible file truncation or corruption
2 participants