libzypp 17.38.5
provide.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9#ifndef ZYPP_NG_MEDIASETFACADE_INCLUDED
10#define ZYPP_NG_MEDIASETFACADE_INCLUDED
11
16#include <zypp-media/ng/LazyMediaHandle>
19
20#include <vector>
21
22namespace zyppng {
25
26
28 public:
29
31
33 ProvideMediaHandle( AttachedMediaInfo_Ptr dataPtr );
34 ProvideRef parent() const;
35 bool isValid () const;
36 const zypp::Url &baseUrl() const;
37 const std::optional<zypp::Pathname> &localPath() const;
38 const AttachedMediaInfo &info ()const;
39
40 private:
41 AttachedMediaInfo_Ptr _data;
42 };
43
44 class ProvideRes {
45 public:
46
48
52 const zypp::Pathname file () const;
53
60 return _res;
61 }
62
67 return _provideHandle;
68 }
69
70#if 0
71
72 Disabled for now so we hit a compile error, since we currently have no way to get those values from the old media backend.
73
77 const zypp::Url &resourceUrl () const {
78 return _resourceUrl;
79 }
80#endif
81
86 const HeaderValueMap &headers () const {
87 return _hdrs;
88 }
89
90 private:
93 // zypp::Url _resourceUrl;
95 };
96
102 class ZYPP_API Provide : public Base
103 {
105 public:
106
107 friend class AttachedMediaInfo;
108
112
114 ~Provide() override;
115
118
122
123 expected<Res> provide( const zypp::MirroredOrigin &origin, const ProvideFileSpec &request );
124 expected<Res> provide( const zypp::Url &url, const ProvideFileSpec &request );
125 expected<Res> provide( const MediaHandle &attachHandle, const zypp::Pathname &fileName, const ProvideFileSpec &request );
126 expected<Res> provide( const LazyMediaHandle &attachHandle, const zypp::Pathname &fileName, const ProvideFileSpec &request );
127
131 expected<zypp::CheckSum> checksumForFile ( const zypp::Pathname &p, const std::string &algorithm );
132
138
139 static auto copyResultToDest ( ProvideRef provider, const zypp::Pathname &targetPath ) {
140 return [ providerRef=std::move(provider), targetPath = targetPath ]( Res &&file ){
141 zypp::filesystem::assert_dir( targetPath.dirname () );
142 return providerRef->copyFile( std::move(file), targetPath );
143 };
144 }
145
146 protected:
147 void releaseMedium ( const AttachedMediaInfo *ptr );
148
149 private:
150 zypp::MirroredOrigin sanitizeUrls(const zypp::MirroredOrigin &origin) const;
151 std::vector<AttachedMediaInfo_Ptr> _attachedMedia;
152 };
153
155
156 //template <bool async>
157 //using MediaFacade = std::conditional_t<async, MediaAsyncFacade, Provide>;
158}
159
160
161
162#endif
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition PtrTypes.h:639
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
Url manipulation class.
Definition Url.h:93
Pathname dirname() const
Return all but the last component od this path.
Definition Pathname.h:133
const zypp::Url & baseUrl() const
Definition provide.cc:127
const std::optional< zypp::Pathname > & localPath() const
Definition provide.cc:134
ProvideRef parent() const
Definition provide.cc:117
const AttachedMediaInfo & info() const
Definition provide.cc:142
AttachedMediaInfo_Ptr _data
Definition provide.h:41
const HeaderValueMap & headers() const
Definition provide.h:86
ProvideRes(ProvideMediaHandle hdl, zypp::ManagedFile file)
Definition provide.cc:147
const zypp::Pathname file() const
Definition provide.cc:152
ProvideMediaHandle _provideHandle
Definition provide.h:92
zypp::ManagedFile _res
Definition provide.h:91
const ProvideMediaHandle & mediaHandle() const
Definition provide.h:66
HeaderValueMap _hdrs
Definition provide.h:94
const zypp::ManagedFile & asManagedFile() const
Definition provide.h:59
ZYPP_DECL_PRIVATE_CONSTR(Provide)
expected< zypp::CheckSum > checksumForFile(const zypp::Pathname &p, const std::string &algorithm)
Definition provide.cc:509
expected< MediaHandle > attachMedia(const zypp::MirroredOrigin &origin, const ProvideMediaSpec &request)
Definition provide.cc:188
expected< LazyMediaHandle > prepareMedia(const zypp::MirroredOrigin &origin, const ProvideMediaSpec &request)
Definition provide.cc:391
friend class AttachedMediaInfo
Definition provide.h:107
ProvideRes Res
Definition provide.h:111
expected< zypp::ManagedFile > copyFile(const zypp::Pathname &source, const zypp::Pathname &target)
Definition provide.cc:518
expected< Res > provide(const zypp::MirroredOrigin &origin, const ProvideFileSpec &request)
Definition provide.cc:419
static auto copyResultToDest(ProvideRef provider, const zypp::Pathname &targetPath)
Definition provide.h:139
::zyppng::LazyMediaHandle< Provide > LazyMediaHandle
Definition provide.h:110
std::vector< AttachedMediaInfo_Ptr > _attachedMedia
Definition provide.h:151
expected< MediaHandle > attachMediaIfNeeded(LazyMediaHandle lazyHandle)
Definition provide.cc:404
ProvideMediaHandle MediaHandle
Definition provide.h:109
unsigned short a
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Definition PathInfo.cc:338
Url details namespace.
Definition UrlBase.cc:58
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Definition ManagedFile.h:27
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
Provide::Res ProvideRes
Definition provide.h:154
#define ZYPP_ADD_CREATE_FUNC(Class)
Definition zyppglobal.h:205
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:126