libzypp 17.32.2
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>
13#include <zypp-core/fs/PathInfo.h>
14#include <zypp-core/base/Gettext.h>
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>
28 expected<RefreshContextRef<ZyppContextRefType>> RefreshContext<ZyppContextRefType>::create( ZyppContextRefType zyppContext, zypp::RepoInfo info, zypp::RepoManagerOptions opts )
29 {
31 using CtxRefType = RefreshContextRef<ZyppContextRefType>;
32
33 zypp::Pathname rawCachePath = zypp::rawcache_path_for_repoinfo ( opts, info );
35
36 if( tmpdir.path().empty() ) {
37 return expected<CtxRefType>::error( ZYPP_EXCPT_PTR(zypp::Exception(_("Can't create metadata cache directory."))) );
38 }
39
40 return expected<CtxRefType>::success( std::make_shared<CtxType>( private_constr_t{}
41 , std::move(zyppContext)
42 , std::move(info)
43 , std::move(rawCachePath)
44 , std::move(tmpdir)
45 , std::move(opts)));
46 }
47
48 template<typename ZyppContextRefType>
50 {
51 MIL << "Deleting RefreshContext" << std::endl;
52 }
53
54 template<typename ZyppContextRefType>
56 {
57 zypp::filesystem::exchange( _tmpDir.path(), _rawCachePath );
58 }
59
60 template<typename ZyppContextRefType>
62 {
63 return _rawCachePath;
64 }
65
66 template<typename ZyppContextRefType>
68 {
69 return _tmpDir.path();
70 }
71
72 template<typename ZyppContextRefType>
73 const ZyppContextRefType &RefreshContext<ZyppContextRefType>::zyppContext() const
74 {
75 return _zyppContext;
76 }
77
78 template<typename ZyppContextRefType>
80 {
81 return _repoInfo;
82 }
83
84 template<typename ZyppContextRefType>
89
90 template<typename ZyppContextRefType>
92 {
93 return _repoManagerOptions;
94 }
95
96 template<typename ZyppContextRefType>
101
102 template<typename ZyppContextRefType>
104 {
105 _policy = newPolicy;
106 }
107
108 template<typename ZyppContextRefType>
109 const std::optional<typename RefreshContext<ZyppContextRefType>::PluginRepoverification> &RefreshContext<ZyppContextRefType>::pluginRepoverification() const
110 {
111 return _pluginRepoverification;
112 }
113
114 template<typename ZyppContextRefType>
116 {
117 if ( _probedType && *_probedType == rType )
118 return;
119
120 _probedType = rType;
121 _sigProbedTypeChanged.emit(rType);
122 }
123
124 template<typename ZyppContextRefType>
125 const std::optional<zypp::repo::RepoType> &RefreshContext<ZyppContextRefType>::probedType() const
126 {
127 return _probedType;
128 }
129
130 template<typename ZyppContextRefType>
132 {
133 return _sigProbedTypeChanged;
134 }
135
136
137 // explicitely intantiate the template types we want to work with
138 template class RefreshContext<SyncContextRef>;
139 template class RefreshContext<ContextRef>;
140
141}
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:114
Provide a new empty temporary directory and recursively delete it when no longer needed.
Definition TmpPath.h:178
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Definition TmpPath.cc:299
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:757
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:28
#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:37
#define MIL
Definition Logger.h:96