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

libzypp 17.36.6

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/zyppng/ui/ProgressObserver>
16#include <zypp-core/zyppng/pipelines/AsyncResult>
17#include <zypp-core/zyppng/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 MediaSyncFacade;
29
30 class ProvideMediaHandle;
31 class SyncMediaHandle;
32
33 using AsyncLazyMediaHandle = LazyMediaHandle<Provide>;
34 using SyncLazyMediaHandle = LazyMediaHandle<MediaSyncFacade>;
35
36 namespace RepoDownloaderWorkflow {
37 AsyncOpRef<expected<repo::AsyncDownloadContextRef>> downloadMasterIndex ( repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle, zypp::filesystem::Pathname masterIndex_r );
38 AsyncOpRef<expected<repo::AsyncDownloadContextRef>> downloadMasterIndex ( repo::AsyncDownloadContextRef dl, AsyncLazyMediaHandle mediaHandle, zypp::filesystem::Pathname masterIndex_r );
39 expected<repo::SyncDownloadContextRef> downloadMasterIndex ( repo::SyncDownloadContextRef dl, SyncMediaHandle mediaHandle, zypp::filesystem::Pathname masterIndex_r );
40 expected<repo::SyncDownloadContextRef> downloadMasterIndex ( repo::SyncDownloadContextRef dl, SyncLazyMediaHandle mediaHandle, zypp::filesystem::Pathname masterIndex_r );
41
42 AsyncOpRef<expected<zypp::RepoStatus>> repoStatus( repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle );
43 AsyncOpRef<expected<zypp::RepoStatus> > repoStatus( repo::AsyncDownloadContextRef dl, AsyncLazyMediaHandle mediaHandle );
44 expected<zypp::RepoStatus> repoStatus( repo::SyncDownloadContextRef dl, SyncMediaHandle mediaHandle );
45 expected<zypp::RepoStatus> repoStatus( repo::SyncDownloadContextRef dl, SyncLazyMediaHandle mediaHandle );
46
47 AsyncOpRef<expected<repo::AsyncDownloadContextRef>> download ( repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle, ProgressObserverRef progressObserver = nullptr );
48 AsyncOpRef<expected<repo::AsyncDownloadContextRef> > download(repo::AsyncDownloadContextRef dl, AsyncLazyMediaHandle mediaHandle, ProgressObserverRef progressObserver);
49 expected<repo::SyncDownloadContextRef> download ( repo::SyncDownloadContextRef dl, SyncMediaHandle mediaHandle, ProgressObserverRef progressObserver = nullptr );
50 expected<repo::SyncDownloadContextRef> download(repo::SyncDownloadContextRef dl, SyncLazyMediaHandle mediaHandle, ProgressObserverRef progressObserver);
51
52 template <typename MediaHandle>
53 auto downloadMediaInfo ( MediaHandle &&mediaHandle, const zypp::filesystem::Pathname &destdir ) {
54 using namespace zyppng::operators;
55 using ProvideType = typename std::decay_t<MediaHandle>::ParentType;
56
57 // check if we have a async media handle
58 constexpr bool isAsync = std::is_same_v<ProvideType, Provide>;
59 auto provider = mediaHandle.parent();
60 if ( !provider )
61 return makeReadyResult<expected<zypp::ManagedFile>, isAsync>( expected<zypp::ManagedFile>::error(ZYPP_EXCPT_PTR(zypp::media::MediaException("Invalid handle"))) );
62
63 return provider->provide( std::forward<MediaHandle>(mediaHandle), "/media.1/media", ProvideFileSpec().setOptional(true).setDownloadSize( zypp::ByteCount(20, zypp::ByteCount::MB ) ))
64 | and_then( ProvideType::copyResultToDest( provider, destdir / "/media.1/media" ) );
65
66 }
67 }
68}
69
70
71#endif
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:47
zypp::media::MediaException
Just inherits Exception to separate media exceptions.
Definition mediaexception.h:37
zyppng::LazyMediaHandle
Definition lazymediahandle.h:19
zyppng::MediaSyncFacade
Definition mediafacade.h:49
zyppng::ProvideFileSpec
Definition providespec.h:92
zyppng::ProvideMediaHandle
Definition provide.h:52
zyppng::ProvideMediaHandle::parent
std::shared_ptr< Provide > parent() const
Definition provide.cc:957
zyppng::Provide
Definition provide.h:112
zyppng::SyncMediaHandle
Definition mediafacade.h:26
zyppng::expected
Definition expected.h:27
zyppng::expected::error
E & error()
Definition expected.h:225
std::decay_t
typename decay< T >::type decay_t
Definition TypeTraits.h:42
zyppng::RepoDownloaderWorkflow
Definition repodownloaderwf.h:36
zyppng::RepoDownloaderWorkflow::download
AsyncOpRef< expected< repo::AsyncDownloadContextRef > > download(repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle, ProgressObserverRef progressObserver=nullptr)
Definition repodownloaderwf.cc:394
zyppng::RepoDownloaderWorkflow::downloadMasterIndex
AsyncOpRef< expected< repo::AsyncDownloadContextRef > > downloadMasterIndex(repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle, zypp::filesystem::Pathname masterIndex_r)
Definition repodownloaderwf.cc:294
zyppng::RepoDownloaderWorkflow::repoStatus
AsyncOpRef< expected< zypp::RepoStatus > > repoStatus(repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle)
Definition repodownloaderwf.cc:348
zyppng::RepoDownloaderWorkflow::downloadMediaInfo
auto downloadMediaInfo(MediaHandle &&mediaHandle, const zypp::filesystem::Pathname &destdir)
Definition repodownloaderwf.h:53
zyppng::operators
Definition asyncresult.h:279
zyppng
Definition MediaCurl2.h:22
zyppng::makeReadyResult
std::conditional_t< isAsync, AsyncOpRef< T >, T > makeReadyResult(T &&result)
Definition asyncop.h:297
zyppng::AsyncOpRef
std::shared_ptr< AsyncOp< T > > AsyncOpRef
Definition asyncop.h:255
zyppng::AsyncLazyMediaHandle
LazyMediaHandle< Provide > AsyncLazyMediaHandle
Definition repodownloaderwf.h:33
zyppng::and_then
ResultType and_then(const expected< T, E > &exp, Function &&f)
Definition expected.h:423
zyppng::SyncLazyMediaHandle
LazyMediaHandle< MediaSyncFacade > SyncLazyMediaHandle
Definition repodownloaderwf.h:34
ZYPP_EXCPT_PTR
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
Definition Exception.h:428
ManagedFile.h