22 #include <zypp-core/base/UserRequestException> 61 struct DownloadFileReportHack :
public callback::ReceiveReport<media::DownloadProgressReport>
63 using BaseType = callback::ReceiveReport<ReportType>;
64 using RedirectType = function<bool (int)>;
66 DownloadFileReportHack(RedirectType &&redirect_r)
67 :
_oldRec(Distributor::instance().getReceiver()),
72 DownloadFileReportHack(
const DownloadFileReportHack &) =
delete;
73 DownloadFileReportHack(DownloadFileReportHack &&) =
delete;
74 DownloadFileReportHack &operator=(
const DownloadFileReportHack &) =
delete;
75 DownloadFileReportHack &operator=(DownloadFileReportHack &&) =
delete;
77 ~DownloadFileReportHack()
override 78 {
if (
_oldRec ) Distributor::instance().setReceiver( *
_oldRec );
else Distributor::instance().noReceiver(); }
80 void start(
const Url & file, Pathname localfile )
override 83 _oldRec->start( file, localfile );
85 BaseType::start( file, localfile );
88 bool progress(
int value,
const Url & file,
double dbps_avg = -1,
double dbps_current = -1 )
override 92 ret &=
_oldRec->progress( value, file, dbps_avg, dbps_current );
98 Action problem(
const Url & file, Error error,
const std::string & description )
override 101 return _oldRec->problem( file, error, description );
102 return BaseType::problem( file, error, description );
104 void finish(
const Url & file, Error error,
const std::string & reason )
override 107 _oldRec->finish( file, error, reason );
109 BaseType::finish( file, error, reason );
126 return access.
provideFile(std::move(repo_r), loc_r, policy_r );
143 std::map<Url, shared_ptr<MediaSetAccess> >::iterator it;
148 it->second->release();
164 std::map<Url, shared_ptr<MediaSetAccess> >::const_iterator it;
166 shared_ptr<MediaSetAccess> media;
184 media->setLabel( repo.
name() );
193 std::map<shared_ptr<MediaSetAccess>,
RepoInfo>::const_iterator it;
197 if ( it->second.alias() == repo.
alias() )
206 DBG <<
"Verifier for repo '" << repo.
alias() <<
"':" << lverifier << endl;
214 WAR <<
"Invalid verifier for repo '" << repo.
alias() <<
"' in '" << repo.
metadataPath() <<
"': " << lverifier << endl;
219 DBG <<
"No media verifier for repo '" << repo.
alias() <<
"' media.1/media does not exist in '" << repo.
metadataPath() <<
"'" << endl;
224 WAR <<
"'" << repo.
alias() <<
"' metadata path is empty. Can't set verifier. Probably this repository does not come from RepoManager." << endl;
230 std::map<Url, shared_ptr<MediaSetAccess> >
_medias;
239 : _impl( new
Impl(
std::move(defaultPolicy_r) ) )
257 MIL << locWithPath << endl;
264 str::form(
_(
"Can't provide file '%s' from repository '%s'"),
266 repo_r.
alias().c_str() ) );
270 if ( repoOrigins.empty() ) {
287 if ( ! pi.isExist() )
293 if ( geteuid() != 0 && ! pi.userMayW() )
295 WAR <<
"Destination dir '" << destinationDir <<
"' is not user writable, using tmp space." << endl;
296 destinationDir = getZYpp()->tmpPath() / destinationDir;
299 MIL <<
"Added cache path " << destinationDir << endl;
304 for (
const auto &origin : repoOrigins )
307 if ( !origin.isValid() ) {
308 MIL <<
"Skipping empty Url group" << std::endl;
314 MIL <<
"Providing file of repo '" << repo_r.
alias() <<
"' from: ";
315 std::for_each( origin.begin (), origin.end(), [&](
const OriginEndpoint &u ){
325 fetcher.
start( destinationDir, *access );
339 MIL <<
"provideFile at " << ret << endl;
356 WAR <<
"Trying next url" << endl;
Pathname path() const
Repository path.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
bool progress(int value) const
Evaluate callback.
MirroredOriginSet repoOrigins() const
The repodata origins.
const char * c_str() const
String representation.
What is known about a repository.
const zypp::Url & url() const
void addCachePath(const Pathname &cache_dir)
adds a directory to the list of directories where to look for cached files
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
void remember(const Exception &old_r)
Store an other Exception as history.
Policy for provideFile and RepoMediaAccess.
void start(const Pathname &dest_dir, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
start the transfer to a destination directory dest_dir The media has to be provides with setMediaSetA...
bool empty() const
Test for an empty path.
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
ManagedFile provideFile(RepoInfo repo_r, const OnMediaLocation &loc_r, const ProvideFilePolicy &policy_r)
Provide a file from a Repository.
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
std::string alias() const
unique identifier for this source.
bool isExist() const
Return whether valid stat info exists.
ProvideFilePolicy & fileChecker(FileChecker fileChecker_r)
Add a FileCecker passed down to the Fetcher.
Pathname metadataPath() const
Path where this repo metadata was read from.
int unlink(const Pathname &path)
Like 'unlink'.
Pathname predownloadPath() const
Path where this repo packages are predownloaded.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
Base class for Exception.
Exception for repository handling.
std::string name() const
Repository name.
Wrapper for const correct access via Smart pointer types.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Pathname packagesPath() const
Path where this repo packages are cached.
Wrapper class for ::stat/::lstat.
Base for exceptions caused by explicit user request.
void enqueue(const OnMediaLocation &resource, const FileChecker &checker=FileChecker())
Enqueue a object for transferal, they will not be transferred until start() is called.
Easy-to use interface to the ZYPP dependency resolver.
const OriginEndpoint & authority() const
Represents a single, configurable network endpoint, combining a URL with specific access settings...
This class allows to retrieve a group of files in a confortable way, providing some smartness that do...