repo_cache.rs 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. //! The dashboard's view of the on-disk recipe-repo cache.
  2. //!
  3. //! The dashboard is long-lived: a repo cloned after it started (a manual
  4. //! sync, the background loop, a first boot whose sync failed) must not wait
  5. //! for a container restart. The CLI paths get the roots at process start,
  6. //! so this merge is private to the report refresher's own config copy.
  7. use crate::config::Config;
  8. /// Fold the on-disk recipe-repo cache into the dashboard's own config copy.
  9. /// Returns true when a new root appeared (the caller must re-collect).
  10. ///
  11. /// The dashboard is long-lived: a repo cloned after it started must not wait
  12. /// for a container restart. The CLI paths get the roots at process start, so
  13. /// this copy is private to the refresher.
  14. pub(crate) fn merge_roots(cfg: &mut Config) -> bool {
  15. // Only the cache of *configured* repos: an install that lists no repos
  16. // must not resurrect stale clones (and the panel says so explicitly).
  17. if cfg.recipe_repos.is_empty() {
  18. return false;
  19. }
  20. let mut changed = false;
  21. for root in crate::recipe_repos::cached_roots() {
  22. let src = root.join("recipes").display().to_string();
  23. if !cfg.recipe_sources.contains(&src) {
  24. cfg.recipe_sources.push(src);
  25. cfg.docker_image_sources.push(root.display().to_string());
  26. changed = true;
  27. }
  28. }
  29. changed
  30. }