mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
depot_download: limit fetchurl download attempts
This commit is contained in:
parent
c21e5863b9
commit
a4b94dad41
@ -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) {
|
||||
|
@ -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> _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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user