libzypp 17.37.18
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
15#include <zypp-media/ng/LazyMediaHandle>
18
19#include <vector>
20
21namespace zyppng {
24
25
27 public:
28
30
32 ProvideMediaHandle( AttachedMediaInfo_Ptr dataPtr );
33 ProvideRef parent() const;
34 bool isValid () const;
35 const zypp::Url &baseUrl() const;
36 const std::optional<zypp::Pathname> &localPath() const;
37 const AttachedMediaInfo &info ()const;
38
39 private:
40 AttachedMediaInfo_Ptr _data;
41 };
42
43 class ProvideRes {
44 public:
45
47
51 const zypp::Pathname file () const;
52
59 return _res;
60 }
61
66 return _provideHandle;
67 }
68
69#if 0
70
71 Disabled for now so we hit a compile error, since we currently have no way to get those values from the old media backend.
72
76 const zypp::Url &resourceUrl () const {
77 return _resourceUrl;
78 }
79#endif
80
85 const HeaderValueMap &headers () const {
86 return _hdrs;
87 }
88
89 private:
92 // zypp::Url _resourceUrl;
94 };
95
101 class ZYPP_API Provide : public Base
102 {
104 public:
105
106 friend class AttachedMediaInfo;
107
111
113 ~Provide() override;
114
117
121
122 expected<Res> provide( const zypp::MirroredOrigin &origin, const ProvideFileSpec &request );
123 expected<Res> provide( const zypp::Url &url, const ProvideFileSpec &request );
124 expected<Res> provide( const MediaHandle &attachHandle, const zypp::Pathname &fileName, const ProvideFileSpec &request );
125 expected<Res> provide( const LazyMediaHandle &attachHandle, const zypp::Pathname &fileName, const ProvideFileSpec &request );
126
130 expected<zypp::CheckSum> checksumForFile ( const zypp::Pathname &p, const std::string &algorithm );
131
135 expected<zypp::ManagedFile> copyFile ( const zypp::Pathname &source, const zypp::Pathname &target );
136 expected<zypp::ManagedFile> copyFile ( Res source, const zypp::Pathname &target );
137
138 static auto copyResultToDest ( ProvideRef provider, const zypp::Pathname &targetPath ) {
139 return [ providerRef=std::move(provider), targetPath = targetPath ]( Res &&file ){
140 zypp::filesystem::assert_dir( targetPath.dirname () );
141 return providerRef->copyFile( std::move(file), targetPath );
142 };
143 }
144
145 protected:
146 void releaseMedium ( const AttachedMediaInfo *ptr );
147
148 private:
149 zypp::MirroredOrigin sanitizeUrls(const zypp::MirroredOrigin &origin) const;
150 std::vector<AttachedMediaInfo_Ptr> _attachedMedia;
151 };
152
154
155 //template <bool async>
156 //using MediaFacade = std::conditional_t<async, MediaAsyncFacade, Provide>;
157}
158
159
160
161#endif
#define ZYPP_API
Definition Globals.h:69
#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:126
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:40
const HeaderValueMap & headers() const
Definition provide.h:85
ProvideRes(ProvideMediaHandle hdl, zypp::ManagedFile file)
Definition provide.cc:147
const zypp::Pathname file() const
Definition provide.cc:152
ProvideMediaHandle _provideHandle
Definition provide.h:91
zypp::ManagedFile _res
Definition provide.h:90
const ProvideMediaHandle & mediaHandle() const
Definition provide.h:65
HeaderValueMap _hdrs
Definition provide.h:93
const zypp::ManagedFile & asManagedFile() const
Definition provide.h:58
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:106
ProvideRes Res
Definition provide.h:110
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:138
::zyppng::LazyMediaHandle< Provide > LazyMediaHandle
Definition provide.h:109
std::vector< AttachedMediaInfo_Ptr > _attachedMedia
Definition provide.h:150
expected< MediaHandle > attachMediaIfNeeded(LazyMediaHandle lazyHandle)
Definition provide.cc:404
ProvideMediaHandle MediaHandle
Definition provide.h:108
unsigned short a
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Definition PathInfo.cc:324
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
Provide::Res ProvideRes
Definition provide.h:153
#define ZYPP_ADD_CREATE_FUNC(Class)
Definition zyppglobal.h:205
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:126