Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ impl Answer {
/// Replaces the kept answer through a renamed temporary file, so a reader
/// never sees half of it.
pub fn write(&self, directory: &Path) -> io::Result<()> {
// Serialize the answer and make sure the cache directory exists
let bytes = serde_json::to_vec(self).map_err(io::Error::other)?;
// Serialize the answer as one line ending in a newline, and make sure
// the cache directory exists
let mut bytes = serde_json::to_vec(self).map_err(io::Error::other)?;
bytes.push(b'\n');
fs::create_dir_all(directory)?;

// Rename only a completely written file over the kept answer
Expand Down
Loading