| 1234567891011121314151617181920212223242526272829303132 |
- //! The dashboard's view of the on-disk recipe-repo cache.
- //!
- //! The dashboard is long-lived: a repo cloned after it started (a manual
- //! sync, the background loop, a first boot whose sync failed) must not wait
- //! for a container restart. The CLI paths get the roots at process start,
- //! so this merge is private to the report refresher's own config copy.
- use crate::config::Config;
- /// Fold the on-disk recipe-repo cache into the dashboard's own config copy.
- /// Returns true when a new root appeared (the caller must re-collect).
- ///
- /// The dashboard is long-lived: a repo cloned after it started must not wait
- /// for a container restart. The CLI paths get the roots at process start, so
- /// this copy is private to the refresher.
- pub(crate) fn merge_roots(cfg: &mut Config) -> bool {
- // Only the cache of *configured* repos: an install that lists no repos
- // must not resurrect stale clones (and the panel says so explicitly).
- if cfg.recipe_repos.is_empty() {
- return false;
- }
- let mut changed = false;
- for root in crate::recipe_repos::cached_roots() {
- let src = root.join("recipes").display().to_string();
- if !cfg.recipe_sources.contains(&src) {
- cfg.recipe_sources.push(src);
- cfg.docker_image_sources.push(root.display().to_string());
- changed = true;
- }
- }
- changed
- }
|