From 9e42c94e306db6ab2b7e1918de16e020a3c01456 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 19 Apr 2023 14:08:30 +0200 Subject: [PATCH] sculpt: handle deploy downloads by download queue By managing downloads issued by the deploy subsystem via the 'Download_queue', failed downloads (e.g., due to HTTP error 404) are properly tracked and don't cause infinite re-attempts. Issue #4818 --- repos/gems/src/app/depot_deploy/child.h | 17 +++++++++++------ repos/gems/src/app/depot_deploy/children.h | 7 +++++++ repos/gems/src/app/sculpt_manager/deploy.h | 9 +++++---- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/repos/gems/src/app/depot_deploy/child.h b/repos/gems/src/app/depot_deploy/child.h index e223ae7763..889a269aee 100644 --- a/repos/gems/src/app/depot_deploy/child.h +++ b/repos/gems/src/app/depot_deploy/child.h @@ -312,17 +312,22 @@ class Depot_deploy::Child : public List_model::Element Depot_rom_server const &cached_depot_rom, Depot_rom_server const &uncached_depot_rom) const; + template + void with_missing_pkg_path(FN const &fn) const + { + if (_pkg_incomplete) + fn(_config_pkg_path()); + } + /** * Generate installation entry needed for the completion of the child */ void gen_installation_entry(Xml_generator &xml) const { - if (!_pkg_incomplete) return; - - xml.node("archive", [&] () { - xml.attribute("path", _config_pkg_path()); - xml.attribute("source", "no"); - }); + with_missing_pkg_path([&] (Archive::Path const &path) { + xml.node("archive", [&] () { + xml.attribute("path", path); + xml.attribute("source", "no"); }); }); } bool incomplete() const { return _pkg_incomplete; } diff --git a/repos/gems/src/app/depot_deploy/children.h b/repos/gems/src/app/depot_deploy/children.h index 69038ca958..0a9ef2e773 100644 --- a/repos/gems/src/app/depot_deploy/children.h +++ b/repos/gems/src/app/depot_deploy/children.h @@ -136,6 +136,13 @@ class Depot_deploy::Children child.gen_installation_entry(xml); }); } + template + void for_each_missing_pkg_path(FN const &fn) const + { + _children.for_each([&] (Child const &child) { + child.with_missing_pkg_path(fn); }); + } + size_t count() const { size_t count = 0; diff --git a/repos/gems/src/app/sculpt_manager/deploy.h b/repos/gems/src/app/sculpt_manager/deploy.h index 26aa60fbed..c2864c8dfb 100644 --- a/repos/gems/src/app/sculpt_manager/deploy.h +++ b/repos/gems/src/app/sculpt_manager/deploy.h @@ -54,7 +54,7 @@ struct Sculpt::Deploy Attached_rom_dataspace const &_launcher_listing_rom; Attached_rom_dataspace const &_blueprint_rom; - Download_queue const &_download_queue; + Download_queue &_download_queue; typedef String<16> Arch; Arch _arch { }; @@ -195,7 +195,6 @@ struct Sculpt::Deploy bool update_needed() const { return _manual_installation_scheduled - || _children.any_incomplete() || _download_queue.any_active_download(); } @@ -281,9 +280,11 @@ struct Sculpt::Deploy if (_installation.try_generate_manually_managed()) return; + _children.for_each_missing_pkg_path([&] (Depot::Archive::Path const path) { + _download_queue.add(path, Verify { true }); }); + _installation.generate([&] (Xml_generator &xml) { xml.attribute("arch", _arch); - _children.gen_installation_entries(xml); _download_queue.gen_installation_entries(xml); }); } @@ -295,7 +296,7 @@ struct Sculpt::Deploy Depot_query &depot_query, Attached_rom_dataspace const &launcher_listing_rom, Attached_rom_dataspace const &blueprint_rom, - Download_queue const &download_queue) + Download_queue &download_queue) : _env(env), _alloc(alloc), _child_states(child_states), _runtime_info(runtime_info),