libzypp 17.35.19
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
27 template<typename ZyppContextRefType>
29 {
30 using namespace operators;
32 using CtxRefType = RefreshContextRef<ZyppContextRefType>;
33
34 return rawcache_path_for_repoinfo ( repoManager->options(), info )
36
38 if( tmpdir.path().empty() && geteuid() != 0 ) {
39 tmpdir = zypp::filesystem::TmpDir(); // non-root user may not be able to write the cache
40 }
41 if( tmpdir.path().empty() ) {
42 return expected<CtxRefType>::error( ZYPP_EXCPT_PTR(zypp::Exception(_("Can't create metadata cache directory."))) );
43 }
44
45 MIL << "Creating RefreshContext " << std::endl;
46
47 return expected<CtxRefType>::success( std::make_shared<CtxType>( private_constr_t{}
48 , std::move(zyppContext)
49 , std::move(info)
50 , std::move(rawCachePath)
51 , std::move(tmpdir)
52 , std::move(repoManager)));
53 } );
54 }
55
56 template<typename ZyppContextRefType>
58 {
59 MIL << "Deleting RefreshContext" << std::endl;
60 }
61
62 template<typename ZyppContextRefType>
67
68 template<typename ZyppContextRefType>
73
74 template<typename ZyppContextRefType>
79
80 template<typename ZyppContextRefType>
81 const ZyppContextRefType &RefreshContext<ZyppContextRefType>::zyppContext() const
82 {
83 return _zyppContext;
84 }
85
86 template<typename ZyppContextRefType>
88 {
89 return _repoInfo;
90 }
91
92 template<typename ZyppContextRefType>
94 {
95 return _repoInfo;
96 }
97
98 template<typename ZyppContextRefType>
99 const RepoManagerRef<ZyppContextRefType> &RefreshContext<ZyppContextRefType>::repoManager() const
102 }
103
104 template<typename ZyppContextRefType>
107 return _repoManager->options();
108 }
109
110 template<typename ZyppContextRefType>
115
116 template<typename ZyppContextRefType>
122 template<typename ZyppContextRefType>
123 const std::optional<typename RefreshContext<ZyppContextRefType>::PluginRepoverification> &RefreshContext<ZyppContextRefType>::pluginRepoverification() const
124 {
126 }
127
128 template<typename ZyppContextRefType>
130 {
131 if ( _probedType && *_probedType == rType )
132 return;
133
134 _probedType = rType;
135 _sigProbedTypeChanged.emit(rType);
136 }
137
138 template<typename ZyppContextRefType>
139 const std::optional<zypp::repo::RepoType> &RefreshContext<ZyppContextRefType>::probedType() const
140 {
141 return _probedType;
142 }
143
144 template<typename ZyppContextRefType>
149
150 // explicitely intantiate the template types we want to work with
151 template class RefreshContext<SyncContextRef>;
152 template class RefreshContext<ContextRef>;
153
154}
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:182
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Definition TmpPath.cc:303
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
const zypp::RepoManagerOptions & repoManagerOptions() const
Definition refresh.cc:105
const RepoManagerRef< ZyppContextRefType > & repoManager() const
Definition refresh.cc:99
void setProbedType(zypp::repo::RepoType rType)
Definition refresh.cc:129
const std::optional< zypp::repo::RepoType > & probedType() const
Definition refresh.cc:139
zypp::Pathname targetDir() const
Definition refresh.cc:75
std::optional< PluginRepoverification > _pluginRepoverification
Definition refresh.h:132
std::optional< zypp::repo::RepoType > _probedType
Definition refresh.h:134
zypp::filesystem::TmpDir _tmpDir
Definition refresh.h:130
RawMetadataRefreshPolicy policy() const
Definition refresh.cc:111
const std::optional< PluginRepoverification > & pluginRepoverification() const
Definition refresh.cc:123
static expected< repo::RefreshContextRef< ZyppContextRefType > > create(ZyppContextRefType zyppContext, zypp::RepoInfo info, RepoManagerRef< ContextRefType > repoManager)
Definition refresh.cc:28
void setPolicy(RawMetadataRefreshPolicy newPolicy)
Definition refresh.cc:117
const ZyppContextRefType & zyppContext() const
Definition refresh.cc:81
repo::RawMetadataRefreshPolicy _policy
Definition refresh.h:131
ZyppContextRefType _zyppContext
Definition refresh.h:126
const zypp::RepoInfo & repoInfo() const
Definition refresh.cc:87
RepoManagerRef< ContextRefType > _repoManager
Definition refresh.h:127
const zypp::Pathname & rawCachePath() const
Definition refresh.cc:69
Signal< void(zypp::repo::RepoType)> _sigProbedTypeChanged
Definition refresh.h:135
zypp::Pathname _rawCachePath
Definition refresh.h:129
SignalProxy< void(zypp::repo::RepoType)> sigProbedTypeChanged()
Definition refresh.cc:145
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