libzypp 17.37.17
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>
16
17namespace zyppng::repo {
18
19 template<typename ZyppContextRefType>
20 RefreshContext<ZyppContextRefType>::RefreshContext( private_constr_t, ZyppContextRefType &&zyppContext, zypp::RepoInfo &&info, zypp::Pathname &&rawCachePath, zypp::filesystem::TmpDir &&tempDir, RepoManagerRef<ContextRefType> &&repoManager )
21 : _zyppContext( std::move(zyppContext) )
22 , _repoManager( std::move(repoManager) )
23 , _repoInfo( std::move(info) )
24 , _rawCachePath( std::move(rawCachePath) )
25 , _tmpDir( std::move(tempDir) )
26 {
27 if ( _repoManager->pluginRepoverification().checkIfNeeded() )
28 _pluginRepoverification = _repoManager->pluginRepoverification();
29 }
30
31 template<typename ZyppContextRefType>
33 {
34 using namespace operators;
36 using CtxRefType = RefreshContextRef<ZyppContextRefType>;
37
38 return rawcache_path_for_repoinfo ( repoManager->options(), info )
40
42 if( tmpdir.path().empty() && geteuid() != 0 ) {
43 tmpdir = zypp::filesystem::TmpDir(); // non-root user may not be able to write the cache
44 }
45 if( tmpdir.path().empty() ) {
46 return expected<CtxRefType>::error( ZYPP_EXCPT_PTR(zypp::Exception(_("Can't create metadata cache directory."))) );
47 }
48
49 MIL << "Creating RefreshContext " << std::endl;
50
51 return expected<CtxRefType>::success( std::make_shared<CtxType>( private_constr_t{}
52 , std::move(zyppContext)
53 , std::move(info)
54 , std::move(rawCachePath)
55 , std::move(tmpdir)
56 , std::move(repoManager)));
57 } );
58 }
59
60 template<typename ZyppContextRefType>
62 {
63 MIL << "Deleting RefreshContext" << std::endl;
64 }
65
66 template<typename ZyppContextRefType>
68 {
69 // RepoMirrorList may have updated the mirrorlist file in the old
70 // metadata dir. We transfer it to the new dir.
73 if ( zypp::PathInfo(oldCache).isExist() && not zypp::PathInfo(newCache).isExist() ) {
76 }
77 }
79 }
80
81 template<typename ZyppContextRefType>
86
87 template<typename ZyppContextRefType>
92
93 template<typename ZyppContextRefType>
94 const ZyppContextRefType &RefreshContext<ZyppContextRefType>::zyppContext() const
95 {
96 return _zyppContext;
97 }
98
99 template<typename ZyppContextRefType>
104
105 template<typename ZyppContextRefType>
110
111 template<typename ZyppContextRefType>
112 const RepoManagerRef<ZyppContextRefType> &RefreshContext<ZyppContextRefType>::repoManager() const
113 {
114 return _repoManager;
115 }
116
117 template<typename ZyppContextRefType>
122
123 template<typename ZyppContextRefType>
128
129 template<typename ZyppContextRefType>
134
135 template<typename ZyppContextRefType>
136 const std::optional<typename RefreshContext<ZyppContextRefType>::PluginRepoverification> &RefreshContext<ZyppContextRefType>::pluginRepoverification() const
137 {
139 }
140
141 template<typename ZyppContextRefType>
143 {
144 if ( _probedType && *_probedType == rType )
145 return;
146
147 _probedType = rType;
148 _sigProbedTypeChanged.emit(rType);
149 }
150
151 template<typename ZyppContextRefType>
152 const std::optional<zypp::repo::RepoType> &RefreshContext<ZyppContextRefType>::probedType() const
153 {
154 return _probedType;
155 }
156
157 template<typename ZyppContextRefType>
162
163 // explicitely intantiate the template types we want to work with
164 template class RefreshContext<SyncContextRef>;
165 template class RefreshContext<ContextRef>;
166
167}
Base class for Exception.
Definition Exception.h:153
What is known about a repository.
Definition RepoInfo.h:72
Wrapper class for stat/lstat.
Definition PathInfo.h:226
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:188
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Definition TmpPath.cc:308
Pathname path() const
Definition TmpPath.cc:152
static constexpr const char * cookieFileName()
static constexpr const char * cacheFileName()
static expected success(ConsParams &&...params)
Definition expected.h:115
static expected error(ConsParams &&...params)
Definition expected.h:126
zypp::RepoInfo _repoInfo
Definition refresh.h:128
const zypp::RepoManagerOptions & repoManagerOptions() const
Definition refresh.cc:118
const RepoManagerRef< ZyppContextRefType > & repoManager() const
Definition refresh.cc:112
void setProbedType(zypp::repo::RepoType rType)
Definition refresh.cc:142
const std::optional< zypp::repo::RepoType > & probedType() const
Definition refresh.cc:152
zypp::Pathname targetDir() const
Definition refresh.cc:88
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:124
const std::optional< PluginRepoverification > & pluginRepoverification() const
Definition refresh.cc:136
static expected< repo::RefreshContextRef< ZyppContextRefType > > create(ZyppContextRefType zyppContext, zypp::RepoInfo info, RepoManagerRef< ContextRefType > repoManager)
Definition refresh.cc:32
void setPolicy(RawMetadataRefreshPolicy newPolicy)
Definition refresh.cc:130
const ZyppContextRefType & zyppContext() const
Definition refresh.cc:94
repo::RawMetadataRefreshPolicy _policy
Definition refresh.h:131
ZyppContextRefType _zyppContext
Definition refresh.h:126
const zypp::RepoInfo & repoInfo() const
Definition refresh.cc:100
RepoManagerRef< ContextRefType > _repoManager
Definition refresh.h:127
const zypp::Pathname & rawCachePath() const
Definition refresh.cc:82
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:158
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition PathInfo.cc:888
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:463
#define _(MSG)
Definition Gettext.h:39
#define MIL
Definition Logger.h:100