Remove refresh checks from the install plan (#1119)

## Summary

Rather than checking cache freshness in the install plan, it's a lot
simple to have the install plan _never_ return cached data when the
refresh policy is in place, and then rely on the distribution database
to check for freshness. The original implementation didn't support this,
since the distribution database was rebuilding things too often. Now, it
rarely rebuilds (it's much better about this), so it seems conceptually
much simpler to split up the responsibilities like this.
This commit is contained in:
Charlie Marsh 2024-01-25 19:48:16 -08:00 committed by GitHub
parent 50057cd5f2
commit f593b65447
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 57 additions and 93 deletions

View file

@ -160,6 +160,15 @@ impl Cache {
CacheEntry::new(self.bucket(cache_bucket).join(dir), file)
}
/// Returns `true` if a cache entry must be revalidated given the [`Refresh`] policy.
pub fn must_revalidate(&self, package: &PackageName) -> bool {
match &self.refresh {
Refresh::None => false,
Refresh::All(_) => true,
Refresh::Packages(packages, _) => packages.contains(package),
}
}
/// Returns `true` if a cache entry is up-to-date given the [`Refresh`] policy.
pub fn freshness(
&self,