pub struct Orphan {
pub path: String,
pub bytes: u64,
}Expand description
A temporary file left in a record directory by a close that did not finish.
The close path writes the durable record to .tmp.XXXX in the destination directory and
renames it, so that no reader ever sees half a record. A process killed between the two
leaves the temporary file behind, where it is untracked, invisible to every reader of the
section, and — because the directory is tracked — offered to the next git add ..
bytes is carried because it is the one thing that decides what to do with the file: a
zero-length temporary file is a close that died before it wrote anything and can simply
go, while a large one is a record that was written and never renamed, and is worth
reading before it is deleted.
use majordomus_cli::capability::builtin::lifecycle::Orphan;
use majordomus_cli::order::canonical;
let mut orphans = vec![
Orphan { path: ".ai/repo/project/sessions/.tmp.b2".into(), bytes: 4_812 },
Orphan { path: ".ai/repo/project/sessions/.tmp.a1".into(), bytes: 0 },
];
canonical(&mut orphans);
// filed under the path, which names one file and so makes the list total
let paths: Vec<&str> = orphans.iter().map(|o| o.path.as_str()).collect();
assert_eq!(paths, [
".ai/repo/project/sessions/.tmp.a1",
".ai/repo/project/sessions/.tmp.b2",
]);
// and the size is what tells a dead stub from a record that was written
assert_eq!(orphans[0].bytes, 0, "nothing was written before the close died");
assert!(orphans[1].bytes > 0, "read this one before removing it");Fields§
§path: StringRepository-relative path.
bytes: u64Its size in bytes, which is how a reader tells an empty stub from a lost record.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Orphan
impl<'de> Deserialize<'de> for Orphan
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Orphan
Source§impl JsonSchema for Orphan
impl JsonSchema for Orphan
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ordered for Orphan
A path names one file, so it is both what a reader looks for and the identity that makes
the orphan list total.
impl Ordered for Orphan
A path names one file, so it is both what a reader looks for and the identity that makes the orphan list total.
impl StructuralPartialEq for Orphan
Auto Trait Implementations§
impl Freeze for Orphan
impl RefUnwindSafe for Orphan
impl Send for Orphan
impl Sync for Orphan
impl Unpin for Orphan
impl UnsafeUnpin for Orphan
impl UnwindSafe for Orphan
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.