pacenotes_installer\ledger/record.rs
1/// What was at a path before the installer first wrote it, which decides what uninstall does.
2#[derive(Clone, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
3#[serde(rename_all = "lowercase")]
4pub enum Prior {
5 /// Nothing: uninstall deletes the file.
6 Absent,
7 /// Another file, copied into this restore point, named per file because a
8 /// path replaced in several runs has a copy in each.
9 Backup { point: String },
10 /// Exactly these bytes, so nothing was copied: uninstall puts the same
11 /// bytes back from the package's payload, or leaves the file when that is gone.
12 Identical,
13}
14
15/// One file an installed package owns.
16#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
17pub struct LedgerFile {
18 /// As written, `/`-separated in its original case; the map key is this folded.
19 pub path: String,
20 /// What the installer wrote, compared before uninstall deletes anything.
21 pub sha256: String,
22 pub prior: Prior,
23}
24
25#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
26pub struct LedgerEntry {
27 /// The package zip's, which is also its cache payload's name.
28 pub sha256: String,
29 pub version: String,
30 /// As installed, so uninstall decisions work offline without a manifest.
31 #[serde(default)]
32 pub exclusive_group: Option<String>,
33 #[serde(default)]
34 pub state: EntryState,
35 /// By folded path.
36 pub files: std::collections::BTreeMap<String, LedgerFile>,
37}
38
39#[derive(Clone, Copy, PartialEq, Eq, Debug, Default, serde::Serialize, serde::Deserialize)]
40#[serde(rename_all = "lowercase")]
41pub enum EntryState {
42 #[default]
43 Installed,
44 /// Recorded before extraction began, so the next run knows a half-written
45 /// file is ours and never backs it up as the user's original.
46 Installing,
47}