pub struct Cache {
pub(super) root: PathBuf,
index: Index,
pub(super) state: IndexState,
}Fields§
§root: PathBuf§index: Index§state: IndexStateImplementations§
Source§impl Cache
impl Cache
Sourcepub fn open(root: impl Into<PathBuf>) -> Cache
pub fn open(root: impl Into<PathBuf>) -> Cache
An index that is missing or cannot be read opens as an empty cache and
leaves the payloads on disk; index_state says which happened.
pub fn index_state(&self) -> IndexState
pub fn root(&self) -> &Path
pub fn get(&self, key: &str) -> Option<&CachedPackage>
Sourcepub fn entries(&self) -> Vec<CachedPackage>
pub fn entries(&self) -> Vec<CachedPackage>
Every entry whose payload is still on disk, so nothing missing is offered as downloaded.
pub(super) fn known_digests(&self) -> BTreeSet<&str>
Sourcepub fn insert(&mut self, package: CachedPackage) -> Result<()>
pub fn insert(&mut self, package: CachedPackage) -> Result<()>
Saves at once, so an interrupted run keeps the download that just finished.
pub fn remove(&mut self, key: &str) -> Result<()>
Source§impl Cache
impl Cache
Sourcepub fn payload_path(&self, sha256: &str) -> PathBuf
pub fn payload_path(&self, sha256: &str) -> PathBuf
Where a payload with this digest lives, whether or not it is there.
Sourcepub fn has_payload(&self, sha256: &str) -> bool
pub fn has_payload(&self, sha256: &str) -> bool
The index can outlive its file, so an install asks this rather than trusting the index.
Sourcepub fn holds(&self, key: &str) -> bool
pub fn holds(&self, key: &str) -> bool
Whether key’s payload is here to install, not merely named by the index.
Sourcepub fn orphans(&self) -> Vec<PathBuf>
pub fn orphans(&self) -> Vec<PathBuf>
Payloads no index entry refers to, for the I9 sweep, and none unless the index was really read, or a damaged index would condemn the whole cache.
Sourcepub fn sweep(&self, in_use: Option<&[String]>) -> Swept
pub fn sweep(&self, in_use: Option<&[String]>) -> Swept
Deletes what a killed download left half-written, and, given in_use
(the digests the ledger and the restore points need), every payload
neither it nor the index names; None deletes no payload, for when
what is needed is unknown, and so does an index that was not read.