libzypp 17.36.1
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;
36
37 return rawcache_path_for_repoinfo ( repoManager->options(), info )
38 | and_then( [&]( zypp::Pathname rawCachePath ) {
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 {
68 zypp::filesystem::exchange( _tmpDir.path(), _rawCachePath );
69 }
70
71 template<typename ZyppContextRefType>
73 {
74 return _rawCachePath;
75 }
76
77 template<typename ZyppContextRefType>
79 {
80 return _tmpDir.path();
81 }
82
83 template<typename ZyppContextRefType>
84 const ZyppContextRefType &RefreshContext<ZyppContextRefType>::zyppContext() const
85 {
86 return _zyppContext;
87 }
88
89 template<typename ZyppContextRefType>
91 {
92 return _repoInfo;
93 }
94
95 template<typename ZyppContextRefType>
100
101 template<typename ZyppContextRefType>
106
107 template<typename ZyppContextRefType>
109 {
110 return _repoManager->options();
111 }
112
113 template<typename ZyppContextRefType>
118
119 template<typename ZyppContextRefType>
124
125 template<typename ZyppContextRefType>
126 const std::optional<typename RefreshContext<ZyppContextRefType>::PluginRepoverification> &RefreshContext<ZyppContextRefType>::pluginRepoverification() const
127 {
128 return _pluginRepoverification;
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}
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:303
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:100