21#include <zypp-core/base/UserRequestException>
60 struct DownloadFileReportHack :
public callback::ReceiveReport<media::DownloadProgressReport>
62 using BaseType = callback::ReceiveReport<ReportType>;
63 using RedirectType = function<
bool (
int)>;
65 DownloadFileReportHack(RedirectType &&redirect_r)
66 :
_oldRec(Distributor::instance().getReceiver()),
71 DownloadFileReportHack(
const DownloadFileReportHack &) =
delete;
72 DownloadFileReportHack(DownloadFileReportHack &&) =
delete;
73 DownloadFileReportHack &operator=(
const DownloadFileReportHack &) =
delete;
74 DownloadFileReportHack &operator=(DownloadFileReportHack &&) =
delete;
76 ~DownloadFileReportHack()
override
77 {
if ( _oldRec ) Distributor::instance().setReceiver( *_oldRec );
else Distributor::instance().noReceiver(); }
79 void start(
const Url & file, Pathname localfile )
override
82 _oldRec->start( file, localfile );
84 BaseType::start( file, localfile );
87 bool progress(
int value,
const Url & file,
double dbps_avg = -1,
double dbps_current = -1 )
override
91 ret &=
_oldRec->progress( value, file, dbps_avg, dbps_current );
97 Action problem(
const Url & file, Error error,
const std::string & description )
override
100 return _oldRec->problem( file, error, description );
101 return BaseType::problem( file, error, description );
103 void finish(
const Url & file, Error error,
const std::string & reason )
override
106 _oldRec->finish( file, error, reason );
108 BaseType::finish( file, error, reason );
142 std::map<Url, shared_ptr<MediaSetAccess> >::iterator
it;
147 it->second->release();
160 std::map<Url, shared_ptr<MediaSetAccess> >::const_iterator
it;
180 media->setLabel( repo.
name() );
187 if (
PathInfo(mediafile).isExist() )
189 std::map<shared_ptr<MediaSetAccess>,
RepoInfo>::const_iterator
it;
193 if (
it->second.alias() == repo.
alias() )
215 DBG <<
"No media verifier for repo '" << repo.
alias() <<
"' media.1/media does not exist in '" << repo.
metadataPath() <<
"'" << endl;
220 WAR <<
"'" << repo.
alias() <<
"' metadata path is empty. Can't set verifier. Probably this repository does not come from RepoManager." << endl;
226 std::map<Url, shared_ptr<MediaSetAccess> >
_medias;
245 {
return _impl->_defaultPolicy; }
260 str::form(
_(
"Can't provide file '%s' from repository '%s'"),
262 repo_r.alias().c_str() ) );
264 if (
repo_r.baseUrlsEmpty() )
272 MIL <<
"Added cache path " <<
repo_r.packagesPath() << endl;
280 if ( !
pi.isExist() )
288 WAR <<
"Destination dir '" <<
destinationDir <<
"' is not user writable, using tmp space." << endl;
306 MIL <<
"Providing file of repo '" <<
repo_r.alias() <<
"' from " << url << endl;
314 if ( !
repo_r.keepPackages() )
319 MIL <<
"provideFile at " <<
ret << endl;
336 WAR <<
"Trying next url" << endl;
void reset()
Reset to default Ctor values.
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
Base class for Exception.
This class allows to retrieve a group of files in a confortable way, providing some smartness that do...
Policy for provideFile and RepoMediaAccess.
bool progress(int value) const
Evaluate callback.
What is known about a repository.
Pathname metadataPath() const
Path where this repo metadata was read from.
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Base for exceptions caused by explicit user request.
Wrapper class for stat/lstat.
bool empty() const
Test for an empty path.
Exception for repository handling.
std::string name() const
Repository name.
std::string alias() const
unique identifier for this source.
int unlink(const Pathname &path)
Like 'unlink'.
ManagedFile provideFile(RepoInfo repo_r, const OnMediaLocation &loc_r, const ProvideFilePolicy &policy_r)
Provide a file from a Repository.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Easy-to use interface to the ZYPP dependency resolver.
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Wrapper for const correct access via Smart pointer types.
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.