aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
28
akode-rs/thread-store/src/local/history_revision.rs
Normal file
28
akode-rs/thread-store/src/local/history_revision.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
//! Validates snapshots of append-only local rollouts before reusing them for resume.
|
||||
//!
|
||||
//! Capture before and after reading; any change or unavailable metadata disables reuse. The
|
||||
//! selected path prevents reuse for a different rollout. Validate under writer ownership,
|
||||
//! before opening the recorder can materialize a compressed file.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
pub(super) async fn read(path: &Path) -> Option<String> {
|
||||
let path = akode_rollout::existing_rollout_path(path).await?;
|
||||
let path = tokio::fs::canonicalize(path).await.ok()?;
|
||||
let metadata = tokio::fs::metadata(&path).await.ok()?;
|
||||
let modified = metadata.modified().ok()?;
|
||||
let created = metadata.created().ok();
|
||||
#[cfg(unix)]
|
||||
let identity = {
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
Some((
|
||||
metadata.dev(),
|
||||
metadata.ino(),
|
||||
metadata.ctime(),
|
||||
metadata.ctime_nsec(),
|
||||
))
|
||||
};
|
||||
#[cfg(not(unix))]
|
||||
let identity: Option<(u64, u64, i64, i64)> = None;
|
||||
serde_json::to_string(&("local", path, metadata.len(), modified, created, identity)).ok()
|
||||
}
|
||||
Reference in New Issue
Block a user