Truncate file to zero size before writing new content, so we do not partially write the file

This commit is contained in:
Matthias Beyer 2016-03-25 15:39:26 +01:00
parent 9f8a648600
commit ab417a17d0

View file

@ -90,6 +90,8 @@ impl StoreEntry {
let file = try!(self.file.create_file());
assert_eq!(self.id, entry.location);
try!(file.set_len(0)
.map_err(|e| StoreError::new(StoreErrorKind::FileError, Some(Box::new(e)))));
file.write_all(entry.to_str().as_bytes())
.map_err(|e| StoreError::new(StoreErrorKind::FileError, Some(Box::new(e))))
} else {