Skip to content

Commit

Permalink
fix RocksDictConfig save not truncating (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
Congyuwang authored Mar 29, 2024
1 parent d740eb4 commit 71e0a1b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/rdict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ impl RocksDictConfig {
}

pub fn save<P: AsRef<Path>>(&self, path: P) -> PyResult<()> {
let config_file = fs::File::options().create(true).write(true).open(path)?;
let config_file = fs::File::options()
.create(true)
.truncate(true)
.write(true)
.open(path)?;
match serde_json::to_writer(config_file, self) {
Ok(_) => Ok(()),
Err(e) => Err(PyException::new_err(e.to_string())),
Expand Down

0 comments on commit 71e0a1b

Please sign in to comment.