13#include <zypp-core/zyppng/pipelines/MTry>
14#include <zypp-media/MediaException>
15#include <zypp-media/ng/Provide>
16#include <zypp-media/ng/ProvideSpec>
18#include <zypp/ng/Context>
29 template <
class Executor,
class OpType>
30 struct ProbeRepoLogic :
public LogicBase<Executor, OpType>
38 using MediaHandle =
typename ProvideType::MediaHandle;
41 ProbeRepoLogic(ZyppContextRefType
zyppCtx, MediaHandle &&
medium,
zypp::Pathname &&path, std::optional<zypp::Pathname> &&targetPath )
49 const auto &url =
_medium.baseUrl();
50 MIL <<
"going to probe the repo type at " << url <<
" (" <<
_path <<
")" << std::endl;
54 MIL <<
"Probed type NONE (not exists) at " << url <<
" (" <<
_path <<
")" << std::endl;
76 std::rethrow_exception (err);
81 DBG <<
"problem checking for repodata/repomd.xml file" << std::endl;
93 |
or_else( [
this]( std::exception_ptr err ) {
96 std::rethrow_exception (err);
101 DBG <<
"problem checking for content file" << std::endl;
113 const auto &url =
_medium.baseUrl();
116 if ( ! ( url.schemeIsDownloading() || url.schemeIsPlugin() ) ) {
120 MIL <<
"Probed type RPMPLAINDIR at " << url <<
" (" <<
_path <<
")" << std::endl;
128 MIL <<
"Probed type NONE at " << url <<
" (" <<
_path <<
")" << std::endl;
143 return std::move(file)
177 template<
typename Executor,
class OpType>
178 struct CheckIfToRefreshMetadataLogic :
public LogicBase<Executor, OpType> {
184 using ZyppContextRefType =
typename RefreshContextRefType::element_type::ContextRefType;
185 using ZyppContextType =
typename RefreshContextRefType::element_type::ContextType;
186 using ProvideType =
typename ZyppContextType::ProvideType;
187 using MediaHandle =
typename ProvideType::MediaHandle;
198 MIL <<
"Going to CheckIfToRefreshMetadata" << std::endl;
206 MIL <<
"Check if to refresh repo " <<
_refreshContext->repoInfo().alias() <<
" at " <<
_medium.baseUrl() <<
" (" << info.type() <<
")" << std::endl;
215 MIL <<
"No cached metadata, going to refresh" << std::endl;
219 if (
_medium.baseUrl().schemeIsVolatile() ) {
220 MIL <<
"Never refresh CD/DVD" << std::endl;
225 MIL <<
"Forced refresh!" << std::endl;
229 if (
_medium.baseUrl().schemeIsLocal() ) {
247 WAR <<
"Repository '" << info.alias() <<
"' was refreshed in the future!" << std::endl;
250 MIL <<
"Repository '" << info.alias()
251 <<
"' has been refreshed less than repo.refresh.delay ("
253 <<
") minutes ago. Advising to skip refresh" << std::endl;
259 MIL <<
"Metadata and solv cache don't match. Check data on server..." << std::endl;
278 MIL <<
"repo has not changed" << std::endl;
283 MIL <<
"repo has changed, going to refresh" << std::endl;
313 template<
typename Executor,
class OpType>
314 struct RefreshMetadataLogic :
public LogicBase<Executor, OpType>{
321 using ZyppContextRefType =
typename RefreshContextRefType::element_type::ContextRefType;
322 using ZyppContextType =
typename RefreshContextRefType::element_type::ContextType;
323 using ProvideType =
typename ZyppContextType::ProvideType;
324 using MediaHandle =
typename ProvideType::MediaHandle;
328 using DlContextRefType = std::shared_ptr<DlContextType>;
335 MIL <<
"Constructor called" << std::endl;
348 MIL <<
"RefreshCheckStatus returned: " << status << std::endl;
355 MIL <<
"Going to refresh metadata from " <<
_medium.baseUrl() << std::endl;
366 _refreshContext->setProbedType( repokind );
368 info.setProbedType( repokind );
387 |
and_then([
this]( DlContextRefType && ) {
410 refreshGeoIPData( info.baseUrls() );
413 RepoException
rexception( info,
PL_(
"Valid metadata not found at specified URL",
414 "Valid metadata not found at specified URLs",
415 info.baseUrlsSize() ) );
431 MIL <<
"Going to refresh metadata from " << url << endl;
434 repo::RepoType
repokind = info.type();
436 repo::RepoType
probed = probe( *
it, info.path() );
443 if ( (
repokind.toEnum() == RepoType::RPMMD_e ) ||
444 (
repokind.toEnum() == RepoType::YAST2_e ) )
449 MIL <<
"Creating downloader for [ " << info.alias() <<
" ]" << endl;
451 if (
repokind.toEnum() == RepoType::RPMMD_e ) {
453 if ( _pluginRepoverification.checkIfNeeded() )
454 downloader_ptr->setPluginRepoverification( _pluginRepoverification );
465 for_(
it, repoBegin(), repoEnd() )
475 else if (
repokind.toEnum() == RepoType::RPMPLAINDIR_e )
478 MediaMounter media( url );
502 ERR <<
"Trying another url..." << endl;
507 if (
it == info.baseUrlsBegin())
514 ERR <<
"No more urls..." << endl;
530 namespace RepoManagerWorkflow {
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void resetDispose()
Set no dispose function.
void reset()
Reset to default Ctor values.
static Date now()
Return the current time.
Base class for Exception.
void remember(const Exception &old_r)
Store an other Exception as history.
What is known about a repository.
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Track changing files or directories.
Wrapper class for stat/lstat.
Exception for repository handling.
thrown when it was impossible to determine this repo type.
A ProvideRes object is a reference counted ownership of a resource in the cache provided by a Provide...
static expected success(ConsParams &&...params)
#define ZYPP_ENABLE_LOGIC_BASE(Executor, OpType)
typename conditional< B, T, F >::type conditional_t
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
int exchange(const Pathname &lpath, const Pathname &rpath)
Exchanges two files or directories.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Pathname rawcache_path_for_repoinfo(const RepoManagerOptions &opt, const RepoInfo &info)
Calculates the raw cache path for a repository, this is usually /var/cache/zypp/alias.
bool isTmpRepo(const RepoInfo &info_r)
Whether repo is not under RM control and provides its own methadata paths.
void assert_alias(const RepoInfo &info)
void assert_urls(const RepoInfo &info)
AsyncOpRef< expected< repo::AsyncDownloadContextRef > > download(repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle, ProgressObserverRef progressObserver=nullptr)
AsyncOpRef< expected< zypp::RepoStatus > > repoStatus(repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle)
AsyncOpRef< expected< zypp::repo::RepoType > > probeRepoType(ContextRef ctx, ProvideMediaHandle medium, zypp::Pathname path, std::optional< zypp::Pathname > targetPath={})
AsyncOpRef< expected< repo::AsyncRefreshContextRef > > refreshMetadata(repo::AsyncRefreshContextRef refCtx, ProvideMediaHandle medium, ProgressObserverRef progressObserver)
AsyncOpRef< expected< repo::RefreshCheckStatus > > checkIfToRefreshMetadata(repo::AsyncRefreshContextRef refCtx, ProvideMediaHandle medium, ProgressObserverRef progressObserver=nullptr)
RefreshCheckStatus
Possibly return state of checkIfRefreshMEtadata function.
@ REFRESH_NEEDED
refresh is needed
@ REPO_CHECK_DELAYED
refresh is delayed due to settings
@ REPO_UP_TO_DATE
repository not changed
@ RefreshIfNeededIgnoreDelay
Exp mtry(F &&f, Args &&...args)
std::conditional_t< isAsync, AsyncOpRef< T >, T > makeReadyResult(T &&result)
typename remove_smart_ptr< T >::type remove_smart_ptr_t
ResultType or_else(const expected< T, E > &exp, Function &&f)
ResultType and_then(const expected< T, E > &exp, Function &&f)
ZyppContextRefType _zyppContext
std::optional< zypp::Pathname > _targetPath
RefreshContextRefType _refreshContext
zypp::repo::RepoException _error
ProgressObserverRef _progress
zypp::Pathname _mediarootpath
static void touchIndexFile(const RepoInfo &info, const RepoManagerOptions &options)
RepoStatus cacheStatus(const RepoInfo &info) const
static RepoStatus metadataStatus(const RepoInfo &info, const RepoManagerOptions &options)
Repository type enumeration.
static const RepoType YAST2
static const RepoType RPMMD
static const RepoType NONE
static const RepoType RPMPLAINDIR
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
#define PL_(MSG1, MSG2, N)