libzypp 17.35.9
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;
33
34 return rawcache_path_for_repoinfo ( repoManager->options(), info )
35 | and_then( [&]( zypp::Pathname rawCachePath ) {
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>
64 {
65 zypp::filesystem::exchange( _tmpDir.path(), _rawCachePath );
66 }
67
68 template<typename ZyppContextRefType>
70 {
71 return _rawCachePath;
72 }
73
74 template<typename ZyppContextRefType>
76 {
77 return _tmpDir.path();
78 }
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>
97
98 template<typename ZyppContextRefType>
103
104 template<typename ZyppContextRefType>
106 {
107 return _repoManager->options();
108 }
109
110 template<typename ZyppContextRefType>
115
116 template<typename ZyppContextRefType>
121
122 template<typename ZyppContextRefType>
123 const std::optional<typename RefreshContext<ZyppContextRefType>::PluginRepoverification> &RefreshContext<ZyppContextRefType>::pluginRepoverification() const
124 {
125 return _pluginRepoverification;
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}
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
Base class for Exception.
Definition Exception.h:147
What is known about a repository.
Definition RepoInfo.h:72
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:301
Definition Arch.h:364
int exchange(const Pathname &lpath, const Pathname &rpath)
Exchanges two files or directories.
Definition PathInfo.cc:761
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.
ResultType and_then(const expected< T, E > &exp, Function &&f)
Definition expected.h:423
ZyppContextRefType _zyppContext
zypp::RepoManagerFlags::CacheBuildPolicy _policy
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:98