libzypp 17.36.7
refresh.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9#include "refresh.h"
11#include <zypp/ng/Context>
15
16namespace zyppng::repo {
17
18 template<typename ZyppContextRefType>
19 RefreshContext<ZyppContextRefType>::RefreshContext( private_constr_t, ZyppContextRefType &&zyppContext, zypp::RepoInfo &&info, zypp::Pathname &&rawCachePath, zypp::filesystem::TmpDir &&tempDir, RepoManagerRef<ContextRefType> &&repoManager )
20 : _zyppContext( std::move(zyppContext) )
21 , _repoManager( std::move(repoManager) )
22 , _repoInfo( std::move(info) )
23 , _rawCachePath( std::move(rawCachePath) )
24 , _tmpDir( std::move(tempDir) )
25 {
26 if ( _repoManager->pluginRepoverification().checkIfNeeded() )
27 _pluginRepoverification = _repoManager->pluginRepoverification();
28 }
29
30 template<typename ZyppContextRefType>
32 {
33 using namespace operators;
35 using CtxRefType = RefreshContextRef<ZyppContextRefType>;
36
37 return rawcache_path_for_repoinfo ( repoManager->options(), info )
39
41 if( tmpdir.path().empty() && geteuid() != 0 ) {
42 tmpdir = zypp::filesystem::TmpDir(); // non-root user may not be able to write the cache
43 }
44 if( tmpdir.path().empty() ) {
45 return expected<CtxRefType>::error( ZYPP_EXCPT_PTR(zypp::Exception(_("Can't create metadata cache directory."))) );
46 }
47
48 MIL << "Creating RefreshContext " << std::endl;
49
50 return expected<CtxRefType>::success( std::make_shared<CtxType>( private_constr_t{}
51 , std::move(zyppContext)
52 , std::move(info)
53 , std::move(rawCachePath)
54 , std::move(tmpdir)
55 , std::move(repoManager)));
56 } );
57 }
58
59 template<typename ZyppContextRefType>
61 {
62 MIL << "Deleting RefreshContext" << std::endl;
63 }
64
65 template<typename ZyppContextRefType>
67 {
69 }
70
71 template<typename ZyppContextRefType>
76
77 template<typename ZyppContextRefType>
82
83 template<typename ZyppContextRefType>
84 const ZyppContextRefType &RefreshContext<ZyppContextRefType>::zyppContext() const
85 {
86 return _zyppContext;
87 }
89 template<typename ZyppContextRefType>
95 template<typename ZyppContextRefType>
101 template<typename ZyppContextRefType>
102 const RepoManagerRef<ZyppContextRefType> &RefreshContext<ZyppContextRefType>::repoManager() const
103 {
104 return _repoManager;
105 }
107 template<typename ZyppContextRefType>
112
113 template<typename ZyppContextRefType>
118
119 template<typename ZyppContextRefType>
122 _policy = newPolicy;
124
125 template<typename ZyppContextRefType>
126 const std::optional<typename RefreshContext<ZyppContextRefType>::PluginRepoverification> &RefreshContext<ZyppContextRefType>::pluginRepoverification() const
127 {
129 }
130
131 template<typename ZyppContextRefType>
133 {
134 if ( _probedType && *_probedType == rType )
135 return;
136
137 _probedType = rType;
138 _sigProbedTypeChanged.emit(rType);
139 }
140
141 template<typename ZyppContextRefType>
142 const std::optional<zypp::repo::RepoType> &RefreshContext<ZyppContextRefType>::probedType() const
143 {
144 return _probedType;
145 }
146
147 template<typename ZyppContextRefType>
152
153 // explicitely intantiate the template types we want to work with
154 template class RefreshContext<SyncContextRef>;
155 template class RefreshContext<ContextRef>;
156
157}
Base class for Exception.
Definition Exception.h:147
What is known about a repository.
Definition RepoInfo.h:72
bool empty() const
Test for an empty path.
Definition Pathname.h:116
Provide a new empty temporary directory and recursively delete it when no longer needed.
Definition TmpPath.h:188
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Definition TmpPath.cc:308
Pathname path() const
Definition TmpPath.cc:152
static expected success(ConsParams &&...params)
Definition expected.h:115
static expected error(ConsParams &&...params)
Definition expected.h:126
zypp::RepoInfo _repoInfo
Definition refresh.h:128
const zypp::RepoManagerOptions & repoManagerOptions() const
Definition refresh.cc:108
const RepoManagerRef< ZyppContextRefType > & repoManager() const
Definition refresh.cc:102
void setProbedType(zypp::repo::RepoType rType)
Definition refresh.cc:132
const std::optional< zypp::repo::RepoType > & probedType() const
Definition refresh.cc:142
zypp::Pathname targetDir() const
Definition refresh.cc:78
std::optional< PluginRepoverification > _pluginRepoverification
Definition refresh.h:132
std::optional< zypp::repo::RepoType > _probedType
Definition refresh.h:134
RawMetadataRefreshPolicy policy() const
Definition refresh.cc:114
const std::optional< PluginRepoverification > & pluginRepoverification() const
Definition refresh.cc:126
static expected< repo::RefreshContextRef< ZyppContextRefType > > create(ZyppContextRefType zyppContext, zypp::RepoInfo info, RepoManagerRef< ContextRefType > repoManager)
Definition refresh.cc:31
void setPolicy(RawMetadataRefreshPolicy newPolicy)
Definition refresh.cc:120
const ZyppContextRefType & zyppContext() const
Definition refresh.cc:84
repo::RawMetadataRefreshPolicy _policy
Definition refresh.h:131
ZyppContextRefType _zyppContext
Definition refresh.h:126
const zypp::RepoInfo & repoInfo() const
Definition refresh.cc:90
RepoManagerRef< ContextRefType > _repoManager
Definition refresh.h:127
const zypp::Pathname & rawCachePath() const
Definition refresh.cc:72
Signal< void(zypp::repo::RepoType)> _sigProbedTypeChanged
Definition refresh.h:135
SignalProxy< void(zypp::repo::RepoType)> sigProbedTypeChanged()
Definition refresh.cc:148
int exchange(const Pathname &lpath, const Pathname &rpath)
Exchanges two files or directories.
Definition PathInfo.cc:761
auto and_then(Fun &&function)
Definition expected.h:623
zypp::RepoManagerFlags::RawMetadataRefreshPolicy RawMetadataRefreshPolicy
Definition refresh.h:33
expected< zypp::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.
Repo manager settings.
Repository type enumeration.
Definition RepoType.h:29
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
Definition Exception.h:428
#define _(MSG)
Definition Gettext.h:39
#define MIL
Definition Logger.h:100