Truncate the feed file before writing
Otherwise, the feed may be overwritten, but if it is shorter, it may contain some leftover data from a previous run. In that case, the file will be invalid XML, thereby failing to be parsed. Signed-off-by: Jacob Kiers <jacob@jacobkiers.net>
This commit is contained in:
parent
ec6034cee7
commit
e4ac6c9657
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Fixed
|
||||
|
||||
* Truncate feed file before writing, to prevent corruption from leftover data.
|
||||
* Ensure the feed file name is part of the self URL. This was still hardcoded to `feed.atom`.
|
||||
|
||||
|
||||
|
|
|
@ -203,6 +203,7 @@ fn write_file<P: Into<PathBuf>, D: AsRef<[u8]>>(html_path: P, data: D) -> Result
|
|||
let path : PathBuf = html_path.into();
|
||||
OpenOptions::new()
|
||||
.write(true)
|
||||
.truncate(true)
|
||||
.create(true)
|
||||
.open(&path)
|
||||
.unwrap_or_else(|_| panic!("Could not open file '{}' for writing", &path.display()))
|
||||
|
|
Loading…
Reference in New Issue