libzypp 17.34.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, zypp::RepoManagerOptions &&opts )
20 : _zyppContext( std::move(zyppContext) )
21 , _repoInfo( std::move(info) )
22 , _rawCachePath( std::move(rawCachePath) )
23 , _tmpDir( std::move(tempDir) )
24 , _repoManagerOptions( std::move(opts) )
25 {}
26
27 template<typename ZyppContextRefType>
29 {
31 using CtxRefType = RefreshContextRef<ZyppContextRefType>;
32
33 zypp::Pathname rawCachePath = zypp::rawcache_path_for_repoinfo ( opts, info );
35 if( tmpdir.path().empty() && geteuid() != 0 ) {
36 tmpdir = zypp::filesystem::TmpDir(); // non-root user may not be able to write the cache
37 }
38 if( tmpdir.path().empty() ) {
39 return expected<CtxRefType>::error( ZYPP_EXCPT_PTR(zypp::Exception(_("Can't create metadata cache directory."))) );
40 }
41
42 return expected<CtxRefType>::success( std::make_shared<CtxType>( private_constr_t{}
43 , std::move(zyppContext)
44 , std::move(info)
45 , std::move(rawCachePath)
46 , std::move(tmpdir)
47 , std::move(opts)));
48 }
49
50 template<typename ZyppContextRefType>
52 {
53 MIL << "Deleting RefreshContext" << std::endl;
54 }
55
56 template<typename ZyppContextRefType>
58 {
59 zypp::filesystem::exchange( _tmpDir.path(), _rawCachePath );
60 }
61
62 template<typename ZyppContextRefType>
64 {
65 return _rawCachePath;
66 }
67
68 template<typename ZyppContextRefType>
70 {
71 return _tmpDir.path();
72 }
73
74 template<typename ZyppContextRefType>
75 const ZyppContextRefType &RefreshContext<ZyppContextRefType>::zyppContext() const
76 {
77 return _zyppContext;
78 }
79
80 template<typename ZyppContextRefType>
82 {
83 return _repoInfo;
84 }
85
86 template<typename ZyppContextRefType>
91
92 template<typename ZyppContextRefType>
94 {
95 return _repoManagerOptions;
96 }
97
98 template<typename ZyppContextRefType>
103
104 template<typename ZyppContextRefType>
106 {
107 _policy = newPolicy;
108 }
109
110 template<typename ZyppContextRefType>
111 const std::optional<typename RefreshContext<ZyppContextRefType>::PluginRepoverification> &RefreshContext<ZyppContextRefType>::pluginRepoverification() const
112 {
113 return _pluginRepoverification;
114 }
115
116 template<typename ZyppContextRefType>
118 {
119 if ( _probedType && *_probedType == rType )
120 return;
121
122 _probedType = rType;
123 _sigProbedTypeChanged.emit(rType);
124 }
125
126 template<typename ZyppContextRefType>
127 const std::optional<zypp::repo::RepoType> &RefreshContext<ZyppContextRefType>::probedType() const
128 {
129 return _probedType;
130 }
131
132 template<typename ZyppContextRefType>
137
138
139 // explicitely intantiate the template types we want to work with
140 template class RefreshContext<SyncContextRef>;
141 template class RefreshContext<ContextRef>;
142
143}
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:301
Pathname path() const
Definition TmpPath.cc:150
Definition Arch.h:364
int exchange(const Pathname &lpath, const Pathname &rpath)
Exchanges two files or directories.
Definition PathInfo.cc:761
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.
RawMetadataRefreshPolicy
Definition refresh.h:31
ZyppContextRefType _zyppContext
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:433
#define _(MSG)
Definition Gettext.h:39
#define MIL
Definition Logger.h:98