diff --git a/repos/gems/src/app/depot_download_manager/import.h b/repos/gems/src/app/depot_download_manager/import.h index d1fbeae19e..160a7f4a25 100644 --- a/repos/gems/src/app/depot_download_manager/import.h +++ b/repos/gems/src/app/depot_download_manager/import.h @@ -56,6 +56,7 @@ class Depot_download_manager::Import enum State { DOWNLOAD_IN_PROGRESS, DOWNLOAD_COMPLETE, + DOWNLOAD_UNAVAILABLE, VERIFIED, VERIFICATION_FAILED, UNPACKED }; @@ -72,6 +73,7 @@ class Depot_download_manager::Import switch (state) { case DOWNLOAD_IN_PROGRESS: return "download"; case DOWNLOAD_COMPLETE: return "verify"; + case DOWNLOAD_UNAVAILABLE: return "unavailable"; case VERIFIED: return "extract"; case VERIFICATION_FAILED: return "verification failed"; case UNPACKED: return "done"; @@ -178,6 +180,13 @@ class Depot_download_manager::Import item.state = Item::DOWNLOAD_COMPLETE; }); } + void all_downloads_unavailable() + { + _items.for_each([&] (Item &item) { + if (item.state == Item::DOWNLOAD_IN_PROGRESS) + item.state = Item::DOWNLOAD_UNAVAILABLE; }); + } + void archive_verified(Archive::Path const &archive) { _items.for_each([&] (Item &item) { diff --git a/repos/gems/src/app/depot_download_manager/main.cc b/repos/gems/src/app/depot_download_manager/main.cc index d9aec3ed1d..15801bdc67 100644 --- a/repos/gems/src/app/depot_download_manager/main.cc +++ b/repos/gems/src/app/depot_download_manager/main.cc @@ -99,6 +99,9 @@ struct Depot_download_manager::Main : Import::Download_progress Depot_query_version _depot_query_count { 1 }; Fetchurl_version _fetchurl_count { 1 }; + unsigned const _fetchurl_max_attempts = 3; + unsigned _fetchurl_attempt = 0; + Archive::User _next_user { }; Constructible _import { }; @@ -281,6 +284,7 @@ void Depot_download_manager::Main::_handle_query_result() /* start new import */ _import.construct(_heap, _current_user_name(), _dependencies.xml()); + _fetchurl_attempt = 0; _update_state_report(); /* spawn fetchurl */ @@ -310,6 +314,12 @@ void Depot_download_manager::Main::_handle_init_state() /* retry by incrementing the version attribute of the start node */ _fetchurl_count.value++; + + if (_fetchurl_attempt++ >= _fetchurl_max_attempts) { + import.all_downloads_unavailable(); + _fetchurl_attempt = 0; + } + reconfigure_init = true; }