libzypp: zypp/ng/repo/workflows/repodownloaderwf.h Source File

libzypp 17.38.13

repodownloaderwf.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9#ifndef ZYPP_NG_REPODOWNLOADER_WORKFLOW_INCLUDED
10#define ZYPP_NG_REPODOWNLOADER_WORKFLOW_INCLUDED
11
12
13#include <zypp/RepoInfo.h>
14#include <zypp/ng/repo/Downloader>
15#include <zypp-core/ng/ui/ProgressObserver>
16#include <zypp-core/ng/async/task.h>
17#include <zypp-core/ng/pipelines/Expected>
18#include <zypp-media/MediaException>
19#include <zypp-media/ng/ProvideSpec>
20#include <zypp-media/ng/LazyMediaHandle>
21
22#include <zypp/ManagedFile.h>
23
24
25namespace zyppng {
26
27 class Provide;
28 class ProvideMediaHandle;
29
30 namespace RepoDownloaderWorkflow {
31 MaybeAwaitable<expected<repo::DownloadContextRef>> downloadMasterIndex ( repo::DownloadContextRef dl, ProvideMediaHandle mediaHandle, zypp::filesystem::Pathname masterIndex_r );
32 MaybeAwaitable<expected<repo::DownloadContextRef>> downloadMasterIndex ( repo::DownloadContextRef dl, LazyMediaHandle<Provide> mediaHandle, zypp::filesystem::Pathname masterIndex_r );
33
34 MaybeAwaitable<expected<zypp::RepoStatus>> repoStatus( repo::DownloadContextRef dl, ProvideMediaHandle mediaHandle );
35 MaybeAwaitable<expected<zypp::RepoStatus> > repoStatus( repo::DownloadContextRef dl, LazyMediaHandle<Provide> mediaHandle );
36
37 MaybeAwaitable<expected<repo::DownloadContextRef>> download ( repo::DownloadContextRef dl, ProvideMediaHandle mediaHandle, ProgressObserverRef progressObserver = nullptr );
38 MaybeAwaitable<expected<repo::DownloadContextRef> > download(repo::DownloadContextRef dl, LazyMediaHandle<Provide> mediaHandle, ProgressObserverRef progressObserver);
39
40 template <typename MediaHandle>
41 auto downloadMediaInfo ( MediaHandle &&mediaHandle, const zypp::filesystem::Pathname &destdir ) {
42 using namespace zyppng::operators;
43 using ProvideType = typename std::decay_t<MediaHandle>::ParentType;
44
45 auto provider = mediaHandle.parent();
46 if ( !provider )
47 return makeReadyTask<expected<zypp::ManagedFile>>( expected<zypp::ManagedFile>::error(ZYPP_EXCPT_PTR(zypp::media::MediaException("Invalid handle"))) );
48
49 return provider->provide( std::forward<MediaHandle>(mediaHandle), "/media.1/media", ProvideFileSpec().setOptional(true).setDownloadSize( zypp::ByteCount(20, zypp::ByteCount::MB ) ).setMirrorsAllowed(false) )
50 | and_then( ProvideType::copyResultToDest( provider, destdir / "/media.1/media" ) );
51
52 }
53 }
54}
55
56
57#endif
ZYPP_EXCPT_PTR
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
Definition Exception.h:463
RepoInfo.h
zypp::ByteCount
Store and operate with byte count.
Definition ByteCount.h:32
zypp::ByteCount::MB
static const Unit MB
1000^2 Byte
Definition ByteCount.h:61
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zypp::media::MediaException
Just inherits Exception to separate media exceptions.
Definition mediaexception.h:37
zyppng::LazyMediaHandle
Definition lazymediahandle.h:20
zyppng::ProvideFileSpec
Definition providespec.h:95
zyppng::ProvideMediaHandle
Definition provide.h:27
zyppng::ProvideMediaHandle::parent
ProvideRef parent() const
Definition provide.cc:117
zyppng::Provide
Definition provide.h:103
zyppng::expected::error
E & error()
Definition expected.h:288
std::decay_t
typename decay< T >::type decay_t
Definition TypeTraits.h:42
zyppng::RepoDownloaderWorkflow
Definition repodownloaderwf.h:30
zyppng::RepoDownloaderWorkflow::repoStatus
MaybeAwaitable< expected< zypp::RepoStatus > > repoStatus(repo::DownloadContextRef dl, ProvideMediaHandle mediaHandle)
Definition repodownloaderwf.cc:459
zyppng::RepoDownloaderWorkflow::download
MaybeAwaitable< expected< repo::DownloadContextRef > > download(repo::DownloadContextRef dl, ProvideMediaHandle mediaHandle, ProgressObserverRef progressObserver=nullptr)
Definition repodownloaderwf.cc:488
zyppng::RepoDownloaderWorkflow::downloadMediaInfo
auto downloadMediaInfo(MediaHandle &&mediaHandle, const zypp::filesystem::Pathname &destdir)
Definition repodownloaderwf.h:41
zyppng::RepoDownloaderWorkflow::downloadMasterIndex
MaybeAwaitable< expected< repo::DownloadContextRef > > downloadMasterIndex(repo::DownloadContextRef dl, ProvideMediaHandle mediaHandle, zypp::filesystem::Pathname masterIndex_r)
Definition repodownloaderwf.cc:422
zyppng::operators
Definition expected.h:699
zyppng
Definition MediaNetworkRequestExecutor.h:16
zyppng::and_then
ResultType and_then(const expected< T, E > &exp, Function &&f)
Definition expected.h:520
ManagedFile.h