diff --git a/libdnf/conf/ConfigMain.cpp b/libdnf/conf/ConfigMain.cpp index 3abcee6c2b..b40f8dcc39 100644 --- a/libdnf/conf/ConfigMain.cpp +++ b/libdnf/conf/ConfigMain.cpp @@ -349,6 +349,7 @@ class ConfigMain::Impl { OptionSeconds timeout{30}; OptionNumber max_parallel_downloads{3, 1}; + OptionNumber max_downloads_per_mirror{3, 1}; OptionSeconds metadata_expire{60 * 60 * 48}; OptionString sslcacert{""}; OptionBool sslverify{true}; @@ -507,6 +508,7 @@ ConfigMain::Impl::Impl(Config & owner) owner.optBinds().add("throttle", throttle); owner.optBinds().add("timeout", timeout); owner.optBinds().add("max_parallel_downloads", max_parallel_downloads); + owner.optBinds().add("max_downloads_per_mirror", max_downloads_per_mirror); owner.optBinds().add("metadata_expire", metadata_expire); owner.optBinds().add("sslcacert", sslcacert); owner.optBinds().add("sslverify", sslverify); @@ -628,6 +630,7 @@ OptionEnum & ConfigMain::ip_resolve() { return pImpl->ip_resolve; } OptionNumber & ConfigMain::throttle() { return pImpl->throttle; } OptionSeconds & ConfigMain::timeout() { return pImpl->timeout; } OptionNumber & ConfigMain::max_parallel_downloads() { return pImpl->max_parallel_downloads; } +OptionNumber & ConfigMain::max_downloads_per_mirror() { return pImpl->max_downloads_per_mirror; } OptionSeconds & ConfigMain::metadata_expire() { return pImpl->metadata_expire; } OptionString & ConfigMain::sslcacert() { return pImpl->sslcacert; } OptionBool & ConfigMain::sslverify() { return pImpl->sslverify; } diff --git a/libdnf/conf/ConfigMain.hpp b/libdnf/conf/ConfigMain.hpp index f43b32870f..19395c71b9 100644 --- a/libdnf/conf/ConfigMain.hpp +++ b/libdnf/conf/ConfigMain.hpp @@ -156,6 +156,7 @@ class ConfigMain : public Config { OptionNumber & throttle(); OptionSeconds & timeout(); OptionNumber & max_parallel_downloads(); + OptionNumber & max_downloads_per_mirror(); OptionSeconds & metadata_expire(); OptionString & sslcacert(); OptionBool & sslverify(); diff --git a/libdnf/conf/ConfigRepo.cpp b/libdnf/conf/ConfigRepo.cpp index 8a485d0e89..1396b73a08 100644 --- a/libdnf/conf/ConfigRepo.cpp +++ b/libdnf/conf/ConfigRepo.cpp @@ -61,6 +61,7 @@ class ConfigRepo::Impl { OptionChild > throttle{mainConfig.throttle()}; OptionChild timeout{mainConfig.timeout()}; OptionChild > max_parallel_downloads{mainConfig.max_parallel_downloads()}; + OptionChild > max_downloads_per_mirror{mainConfig.max_downloads_per_mirror()}; OptionChild metadata_expire{mainConfig.metadata_expire()}; OptionNumber cost{1000}; OptionNumber priority{99}; @@ -155,6 +156,7 @@ ConfigRepo::Impl::Impl(Config & owner, ConfigMain & mainConfig) owner.optBinds().add("throttle", throttle); owner.optBinds().add("timeout", timeout); owner.optBinds().add("max_parallel_downloads", max_parallel_downloads); + owner.optBinds().add("max_downloads_per_mirror", max_downloads_per_mirror); owner.optBinds().add("metadata_expire", metadata_expire); owner.optBinds().add("cost", cost); owner.optBinds().add("priority", priority); @@ -211,6 +213,7 @@ OptionChild > & ConfigRepo::ip_resolve() { return pImpl- OptionChild > & ConfigRepo::throttle() { return pImpl->throttle; } OptionChild & ConfigRepo::timeout() { return pImpl->timeout; } OptionChild > & ConfigRepo::max_parallel_downloads() { return pImpl->max_parallel_downloads; } +OptionChild > & ConfigRepo::max_downloads_per_mirror() { return pImpl->max_downloads_per_mirror; } OptionChild & ConfigRepo::metadata_expire() { return pImpl->metadata_expire; } OptionNumber & ConfigRepo::cost() { return pImpl->cost; } OptionNumber & ConfigRepo::priority() { return pImpl->priority; } diff --git a/libdnf/conf/ConfigRepo.hpp b/libdnf/conf/ConfigRepo.hpp index 0152991417..2b198441ea 100644 --- a/libdnf/conf/ConfigRepo.hpp +++ b/libdnf/conf/ConfigRepo.hpp @@ -75,6 +75,7 @@ class ConfigRepo : public Config { OptionChild > & throttle(); OptionChild & timeout(); OptionChild > & max_parallel_downloads(); + OptionChild > & max_downloads_per_mirror(); OptionChild & metadata_expire(); OptionNumber & cost(); OptionNumber & priority(); diff --git a/libdnf/repo/Repo.cpp b/libdnf/repo/Repo.cpp index 557f727fdf..9959a73aa7 100644 --- a/libdnf/repo/Repo.cpp +++ b/libdnf/repo/Repo.cpp @@ -461,6 +461,8 @@ std::unique_ptr Repo::Impl::lrHandleInitBase() handleSetOpt(h.get(), LRO_MAXMIRRORTRIES, static_cast(maxMirrorTries)); handleSetOpt(h.get(), LRO_MAXPARALLELDOWNLOADS, conf->max_parallel_downloads().getValue()); + handleSetOpt(h.get(), LRO_MAXDOWNLOADSPERMIRROR, + conf->max_downloads_per_mirror().getValue()); LrUrlVars * vars = NULL; vars = lr_urlvars_set(vars, MD_TYPE_GROUP_GZ, MD_TYPE_GROUP); diff --git a/python/hawkey/tests/tests/test_repo.py b/python/hawkey/tests/tests/test_repo.py index 8ae0544c20..0b5a55cca3 100644 --- a/python/hawkey/tests/tests/test_repo.py +++ b/python/hawkey/tests/tests/test_repo.py @@ -40,6 +40,16 @@ def test_cost_assignment(self): with self.assertRaises(TypeError): r2.cost = '4' + def test_max_parallel_downloads(self): + r = hawkey.Repo("fog") + r.max_parallel_downloads = 10 + self.assertEqual(10, r.max_parallel_downloads) + + def test_max_downloads_per_mirror(self): + r = hawkey.Repo("fog") + r.max_downloads_per_mirror = 10 + self.assertEqual(10, r.max_downloads_per_mirror) + def test_str_assignment(self): r = hawkey.Repo('fog') with self.assertRaises(TypeError):