2 Commits

Author SHA1 Message Date
Manuel Raimann 3581187cd3 chore: release v0.9.1 2026-02-12 08:17:28 +01:00
Manuel Raimann 349ffcbed3 fix: update journal file handling to support reading and writing 2026-02-12 08:13:48 +01:00
2 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ members = ["optimizer-derive"]
[package]
name = "optimizer"
version = "0.9.0"
version = "0.9.1"
edition = "2024"
rust-version = "1.89"
license = "MIT"
+8 -3
View File
@@ -2,7 +2,7 @@
use core::marker::PhantomData;
use std::fs::{File, OpenOptions};
use std::io::{BufRead, BufReader, Write};
use std::io::{BufRead, BufReader, Seek, SeekFrom, Write};
use std::path::{Path, PathBuf};
use std::sync::Arc;
@@ -83,18 +83,23 @@ impl<V: Serialize + DeserializeOwned + Send + Sync> JournalStorage<V> {
let mut file = OpenOptions::new()
.create(true)
.append(true)
.truncate(false)
.read(true)
.write(true)
.open(&self.path)
.map_err(|e| crate::Error::Storage(e.to_string()))?;
file.lock_exclusive()
.map_err(|e| crate::Error::Storage(e.to_string()))?;
file.seek(SeekFrom::End(0))
.map_err(|e| crate::Error::Storage(e.to_string()))?;
let line =
serde_json::to_string(trial).map_err(|e| crate::Error::Storage(e.to_string()))?;
writeln!(file, "{line}").map_err(|e| crate::Error::Storage(e.to_string()))?;
file.flush()
file.sync_data()
.map_err(|e| crate::Error::Storage(e.to_string()))?;
file.unlock()