Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3581187cd3 | |||
| 349ffcbed3 |
+1
-1
@@ -3,7 +3,7 @@ members = ["optimizer-derive"]
|
|||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "optimizer"
|
name = "optimizer"
|
||||||
version = "0.9.0"
|
version = "0.9.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.89"
|
rust-version = "1.89"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use std::fs::{File, OpenOptions};
|
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::path::{Path, PathBuf};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@@ -83,18 +83,23 @@ impl<V: Serialize + DeserializeOwned + Send + Sync> JournalStorage<V> {
|
|||||||
|
|
||||||
let mut file = OpenOptions::new()
|
let mut file = OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
.append(true)
|
.truncate(false)
|
||||||
|
.read(true)
|
||||||
|
.write(true)
|
||||||
.open(&self.path)
|
.open(&self.path)
|
||||||
.map_err(|e| crate::Error::Storage(e.to_string()))?;
|
.map_err(|e| crate::Error::Storage(e.to_string()))?;
|
||||||
|
|
||||||
file.lock_exclusive()
|
file.lock_exclusive()
|
||||||
.map_err(|e| crate::Error::Storage(e.to_string()))?;
|
.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 =
|
let line =
|
||||||
serde_json::to_string(trial).map_err(|e| crate::Error::Storage(e.to_string()))?;
|
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()))?;
|
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()))?;
|
.map_err(|e| crate::Error::Storage(e.to_string()))?;
|
||||||
|
|
||||||
file.unlock()
|
file.unlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user