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()),
68 _redirect(std::move(redirect_r)) {
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 );
94 ret &= _redirect( value );
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 );
114 RedirectType _redirect;
126 return access.
provideFile(std::move(repo_r), loc_r, policy_r );
131 std::vector<Pathname> paths;
138 if ( cfg != paths[0] )
139 paths.push_back( cfg );
158 std::map<Url, shared_ptr<MediaSetAccess> >::iterator it;
163 it->second->release();
179 std::map<Url, shared_ptr<MediaSetAccess> >::const_iterator it;
203 Pathname mediafile =
repo.metadataPath() +
"/media.1/media";
204 if ( !
repo.metadataPath().empty() )
206 if (
PathInfo(mediafile).isExist() )
208 std::map<shared_ptr<MediaSetAccess>,
RepoInfo>::const_iterator it;
212 if ( it->second.alias() ==
repo.alias() )
221 DBG <<
"Verifier for repo '" <<
repo.alias() <<
"':" << lverifier << endl;
224 media->setVerifier( i, verifier);
229 WAR <<
"Invalid verifier for repo '" <<
repo.alias() <<
"' in '" <<
repo.metadataPath() <<
"': " << lverifier << endl;
234 DBG <<
"No media verifier for repo '" <<
repo.alias() <<
"' media.1/media does not exist in '" <<
repo.metadataPath() <<
"'" << endl;
239 WAR <<
"'" <<
repo.alias() <<
"' metadata path is empty. Can't set verifier. Probably this repository does not come from RepoManager." << endl;
245 std::map<Url, shared_ptr<MediaSetAccess> >
_medias;
261 {
_impl->_defaultPolicy = policy_r; }
264 {
return _impl->_defaultPolicy; }
272 MIL << locWithPath << endl;
279 str::form(
_(
"Can't provide file '%s' from repository '%s'"),
281 repo_r.
alias().c_str() ) );
285 if ( repoOrigins.empty() ) {
297 MIL <<
"Added cache path " << path << endl;
300 Pathname preloadPath = path /
".preload";
302 MIL <<
"Added cache path " << preloadPath << endl;
317 assert_dir( destinationDir );
323 for (
const auto &origin : repoOrigins )
326 if ( !origin.isValid() ) {
327 MIL <<
"Skipping empty Url group" << std::endl;
333 MIL <<
"Providing file of repo '" << repo_r.
alias() <<
"' from: ";
334 std::for_each( origin.begin (), origin.end(), [&](
const OriginEndpoint &u ){
344 fetcher.
start( destinationDir, *access );
358 MIL <<
"provideFile at " << ret << endl;
375 WAR <<
"Trying next url" << endl;
#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.
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
Base class for Exception.
void remember(const Exception &old_r)
Store an other Exception as history.
This class allows to retrieve a group of files in a confortable way, providing some smartness that do...
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...
void enqueue(const OnMediaLocation &resource, const FileChecker &checker=FileChecker())
Enqueue a object for transferal, they will not be transferred until start() is called.
void addCachePath(const Pathname &cache_dir)
adds a directory to the list of directories where to look for cached files
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
const OriginEndpoint & authority() const
Represents a single, configurable network endpoint, combining a URL with specific access settings.
const zypp::Url & url() const
Policy for provideFile and RepoMediaAccess.
ProvideFilePolicy & fileChecker(FileChecker fileChecker_r)
Add a FileCecker passed down to the Fetcher.
bool progress(int value) const
Evaluate callback.
What is known about a repository.
MirroredOriginSet repoOrigins() const
The repodata origins.
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Pathname path() const
Repository path.
Pathname packagesPath() const
packagesPath Checks if the effective user is allowed to write into the system package cache.
Pathname systemPackagesPath() const
Returns a path to the system-defined package cache.
Base for exceptions caused by explicit user request.
Wrapper class for stat/lstat.
bool isExist() const
Return whether valid stat info exists.
const char * c_str() const
String representation.
Exception for repository handling.
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::vector< Pathname > repositoryCachePaths(RepoInfo repo_r)
returns a set of paths.
SolvableSpec & operator=(const SolvableSpec &)=default
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.