Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --download-max-retries and --download-retry-wait-time switches (bsc#1200370) #442

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Summary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <zypp/ZYppFactory.h>
#include <zypp/base/LogTools.h>
#include <zypp/base/Measure.h>
#include <zypp/base/DtorReset.h>
#include <zypp-core/base/DtorReset>
#include <zypp/ResPool.h>
#include <zypp/Patch.h>
#include <zypp/Package.h>
Expand Down
2 changes: 1 addition & 1 deletion src/Summary.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <zypp/base/PtrTypes.h>
#include <zypp/ByteCount.h>
#include <zypp/base/DefaultIntegral.h>
#include <zypp-core/base/DefaultIntegral>
#include <zypp/ResObject.h>
#include <zypp/ResPool.h>

Expand Down
2 changes: 1 addition & 1 deletion src/Table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <zypp/base/LogTools.h>
#include <zypp/base/String.h>
#include <zypp/base/DtorReset.h>
#include <zypp-core/base/DtorReset>

#include "utils/colors.h"
#include "utils/console.h"
Expand Down
4 changes: 2 additions & 2 deletions src/Zypper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

#include <zypp/base/LogTools.h>
#include <zypp/base/Algorithm.h>
#include <zypp/base/UserRequestException.h>
#include <zypp/base/DtorReset.h>
#include <zypp-core/base/UserRequestException>
#include <zypp-core/base/DtorReset>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIKS the new header file locations are in the buildrequired libzypp version. But if the new ZConfig variable is also used, the buildrequires must be adapted. Preferably in a single committ like 2eb7e57 and before the new featues are used in the code.


#include <zypp/sat/SolvAttr.h>
#include <zypp/AutoDispose.h>
Expand Down
14 changes: 12 additions & 2 deletions src/callbacks/media.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <zypp/base/Logger.h>
#include <zypp/Pathname.h>
#include <zypp/Url.h>
#include <zypp/ZConfig.h>

#include "Zypper.h"

Expand Down Expand Up @@ -100,6 +101,7 @@ namespace ZmartRecipients
{
_last_reported = time(NULL);
_last_drate_avg = -1;
_silentRetries = 0;

Out & out = Zypper::instance().out();

Expand Down Expand Up @@ -154,12 +156,19 @@ namespace ZmartRecipients
problem( const Url & uri, DownloadProgressReport::Error error, const std::string & description )
{
DBG << "media problem" << std::endl;

if (_be_quiet)
Zypper::instance().out().dwnldProgressEnd(uri, _last_drate_avg, true);
Zypper::instance().out().error(zcb_error2str(error, description));

Action action = (Action) read_action_ari(
PROMPT_ARI_MEDIA_PROBLEM, DownloadProgressReport::ABORT);
Action action = DownloadProgressReport::ABORT;
if ( _silentRetries < ZConfig::instance().download_max_silent_tries() ) {
action = (Action) read_action_ari_with_timeout( PROMPT_ARI_MEDIA_PROBLEM, 0, DownloadProgressReport::RETRY );
if ( action == DownloadProgressReport::RETRY )
_silentRetries++;
} else {
action = (Action) read_action_ari( PROMPT_ARI_MEDIA_PROBLEM, DownloadProgressReport::ABORT );
}
if (action == DownloadProgressReport::RETRY)
Zypper::instance().requestExit(false);
return action;
Expand All @@ -179,6 +188,7 @@ namespace ZmartRecipients
bool _be_quiet;
time_t _last_reported;
double _last_drate_avg;
int _silentRetries;
};


Expand Down
11 changes: 10 additions & 1 deletion src/callbacks/repo.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct DownloadResolvableReportReceiver : public callback::ReceiveReport<repo::D
std::string _label_apply_delta;
Pathname _patch;
ByteCount _patch_size;
int _silentRetries;

// Dowmload delta rpm:
// - path below url reported on start()
Expand Down Expand Up @@ -120,6 +121,7 @@ struct DownloadResolvableReportReceiver : public callback::ReceiveReport<repo::D
*/
virtual void start( Resolvable::constPtr resolvable_ptr, const Url & url )
{
_silentRetries = 0;
_resolvable_ptr = resolvable_ptr;
_url = url;
Zypper & zypper = Zypper::instance();
Expand Down Expand Up @@ -147,7 +149,14 @@ struct DownloadResolvableReportReceiver : public callback::ReceiveReport<repo::D
Zypper::instance().out().error(description);
DBG << "error report" << std::endl;

Action action = (Action) read_action_ari(PROMPT_ARI_RPM_DOWNLOAD_PROBLEM, ABORT);
Action action = ABORT;
if ( _silentRetries < ZConfig::instance().download_max_silent_tries() ) {
action = (Action) read_action_ari_with_timeout(PROMPT_ARI_RPM_DOWNLOAD_PROBLEM, 0, RETRY);
if ( action == RETRY )
_silentRetries++;
} else {
action = (Action) read_action_ari(PROMPT_ARI_RPM_DOWNLOAD_PROBLEM, ABORT);
}
if (action == DownloadResolvableReport::RETRY)
--Zypper::instance().runtimeData().commit_pkg_current;
else
Expand Down
15 changes: 15 additions & 0 deletions src/commands/commonflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define ZYPPER_COMMANDS_COMMONFLAGS_INCLUDED

#include "utils/flags/flagtypes.h"
#include <zypp/ZConfig.h>

/**
* \file Contains all flags that are commonly used in multiple commands but which are too simple for a OptionSet
Expand Down Expand Up @@ -45,6 +46,20 @@ namespace CommonFlags
_("Consider only patches which affect the package management itself.")
};
}

inline zypp::ZyppFlags::CommandOption downloadMaxRetriesFlag () {
return {
"download-max-retries", '\0', ZyppFlags::RequiredArgument, ZyppFlags::CallbackVal( []( const auto& opt, const boost::optional<std::string> &in ){
ZConfig::instance().set_download_max_silent_tries(ZyppFlags::argValueConvert<int>(opt, in));
}, ARG_INTEGER ), _("Number of times zypp should attempt a download in case it fails.") };
}

inline zypp::ZyppFlags::CommandOption downloadRetryWaitTimeFlag () {
return {
"download-retry-wait-time", '\0', ZyppFlags::RequiredArgument, ZyppFlags::CallbackVal( []( const auto& opt, const boost::optional<std::string> &in ){
ZConfig::instance().set_download_retry_wait_time(ZyppFlags::argValueConvert<int>(opt, in));
}, ARG_INTEGER ), _("Time in seconds zypp should wait before retrying a failed download.") };
}
}


Expand Down
7 changes: 6 additions & 1 deletion src/commands/optionsets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
|__/|_| |_|
\*---------------------------------------------------------------------------*/
#include "optionsets.h"
#include "commonflags.h"
#include "utils/flags/flagtypes.h"
#include "global-settings.h"
#include "Zypper.h"
Expand Down Expand Up @@ -183,14 +184,18 @@ std::vector<ZyppFlags::CommandGroup> DownloadOptionSet::options()
},
{ "download-in-advance", '\0', ZyppFlags::NoArgument | ZyppFlags::Repeatable | ZyppFlags::Hidden, DownloadModeNoArgType( *this, DownloadMode::DownloadInAdvance ), "" },
{ "download-in-heaps", '\0', ZyppFlags::NoArgument | ZyppFlags::Repeatable | ZyppFlags::Hidden, DownloadModeNoArgType( *this, DownloadMode::DownloadInHeaps ), "" },
{ "download-as-needed", '\0', ZyppFlags::NoArgument | ZyppFlags::Repeatable | ZyppFlags::Hidden, DownloadModeNoArgType( *this, DownloadMode::DownloadAsNeeded ), "" }
{ "download-as-needed", '\0', ZyppFlags::NoArgument | ZyppFlags::Repeatable | ZyppFlags::Hidden, DownloadModeNoArgType( *this, DownloadMode::DownloadAsNeeded ), "" },
CommonFlags::downloadMaxRetriesFlag(),
CommonFlags::downloadRetryWaitTimeFlag()
}}};
}

void DownloadOptionSet::reset()
{
_mode = ZConfig::instance().commit_downloadMode();
_wasSetBefore = false;
ZConfig::instance().reset_download_max_silent_tries();
ZConfig::instance().reset_download_retry_wait_time();
}


Expand Down
5 changes: 5 additions & 0 deletions src/commands/repos/refresh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "repos.h"
#include "commands/conditions.h"
#include "commands/services/refresh.h"
#include "commands/commonflags.h"


#include "utils/messages.h"
Expand Down Expand Up @@ -68,6 +69,8 @@ zypp::ZyppFlags::CommandGroup RefreshRepoCmd::cmdOptions() const
// translators: -D, --download-only
_("Only download raw metadata, don't build the database.")
},
CommonFlags::downloadMaxRetriesFlag(),
CommonFlags::downloadRetryWaitTimeFlag(),
{"repo", 'r', ZyppFlags::RequiredArgument | ZyppFlags::Repeatable,
ZyppFlags::StringVectorType( &that->_repos, ARG_REPOSITORY),
// translators: -r, --repo <ALIAS|#|URI>
Expand All @@ -87,6 +90,8 @@ void RefreshRepoCmd::doReset()
_flags = Default;
_repos.clear();
_services = false;
ZConfig::instance().reset_download_max_silent_tries();
ZConfig::instance().reset_download_retry_wait_time();
}

int RefreshRepoCmd::execute( Zypper &zypper , const std::vector<std::string> &positionalArgs_r )
Expand Down
6 changes: 3 additions & 3 deletions src/output/Out.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include <zypp/base/Exception.h>
#include <zypp/base/String.h>
#include <zypp/base/Flags.h>
#include <zypp/base/DefaultIntegral.h>
#include <zypp/base/DtorReset.h>
#include <zypp-core/base/DefaultIntegral>
#include <zypp-core/base/DtorReset>
#include <zypp/Url.h>
#include <zypp/TriBool.h>
#include <zypp/ProgressData.h>
#include <zypp-core/ui/ProgressData>
#include <zypp/ZYppCallbacks.h>
#include <zypp/base/LogTools.h>

Expand Down
1 change: 1 addition & 0 deletions src/output/prompt.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ typedef enum
PR_ENUM(PROMPT_PACKAGEKIT_QUIT, 23)
PR_ENUM(PROMPT_YN_CONTINUE_ON_FILECONFLICT, 24)
PR_ENUM(PROMPT_YN_RUN_SEARCH_PACKAGES, 25)
PR_ENUM(PROMPT_ARI_RETRY_OPERATION, 26)

#ifndef PROMPT_H_
#define PROMPT_H_
Expand Down
Loading