libzypp 17.38.1
zckhelper.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------/
9*
10* This file contains private API, this might break at any time between releases.
11* You have been warned!
12*
13*/
14#ifndef ZYPPNG_CURL_ZCKHELPER_H_INCLUDED
15#define ZYPPNG_CURL_ZCKHELPER_H_INCLUDED
16
19
21#include <zypp-core/ng/base/Base>
22
23extern "C" {
24 typedef struct zckCtx zckCtx;
25}
26
27namespace zyppng {
28
30
32 {
33 public:
34 ZckError( const std::string & msg_r );
35 ZckError( std::string && msg_r );
36 };
37
38 class ZckLoader : public Base {
39 public:
40
48
50
52 enum Code {
53 Error, // we got an error
54 NothingToDo, // Target file is already complete
55 ExceedsMaxLen, // Zchunk header reports a different filesize than what was expected
56 Success // Returns a list of blocks to fetch
57 };
58
60 std::vector<Block> _blocks;
62 std::string _message;
63 };
64
65
70 expected<void> buildZchunkFile( const zypp::Pathname &target, const zypp::Pathname &delta, const std::optional<zypp::ByteCount> &expectedFileSize, const std::optional<zypp::ByteCount> &zcKHeaderSize );
71
77
81 void setFailed( const std::string &msg );
82
87 SignalProxy<void(const std::vector<Block> &)> sigBlocksRequired();
88
93
94
99
103 static bool isZchunkFile(const zypp::Pathname &file);
104
109 static PrepareResult prepareZck ( const zypp::Pathname &delta, const zypp::Pathname &target, const zypp::ByteCount &expectedFileSize );
110
114 static bool validateZckFile( const zypp::Pathname &file, std::string &error );
115
116
117 private:
122
125 std::optional<zypp::ByteCount> _expectedFileSize;
126 std::optional<zypp::ByteCount> _zcKHeaderSize;
127
128 Signal<void(const std::vector<Block> &)> _sigBlocksRequired;
130 };
131}
132#endif
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
Store and operate with byte count.
Definition ByteCount.h:32
Base class for Exception.
Definition Exception.h:153
ZckError(const std::string &msg_r)
Definition zckhelper.cc:21
static PrepareResult prepareZck(const zypp::Pathname &delta, const zypp::Pathname &target, const zypp::ByteCount &expectedFileSize)
Definition zckhelper.cc:322
static bool validateZckFile(const zypp::Pathname &file, std::string &error)
Definition zckhelper.cc:457
void setFailed(const std::string &msg)
Definition zckhelper.cc:279
std::optional< zypp::ByteCount > _expectedFileSize
Definition zckhelper.h:125
expected< void > buildZchunkFile(const zypp::Pathname &target, const zypp::Pathname &delta, const std::optional< zypp::ByteCount > &expectedFileSize, const std::optional< zypp::ByteCount > &zcKHeaderSize)
Definition zckhelper.cc:27
expected< void > cont()
Definition zckhelper.cc:69
Signal< void(PrepareResult)> _sigFinished
Definition zckhelper.h:129
zypp::Pathname _delta
Definition zckhelper.h:124
zypp::ByteCount _bytesReused
Definition zckhelper.h:121
SignalProxy< void(PrepareResult)> sigFinished()
Called once the zchunk build process is finished, either with error or success.
Definition zckhelper.cc:299
zypp::AutoDispose< zckCtx * > _zchunkContext
Definition zckhelper.h:119
RangeDesc Block
Definition zckhelper.h:49
zypp::Pathname _target
Definition zckhelper.h:123
static bool isZchunkFile(const zypp::Pathname &file)
Definition zckhelper.cc:309
SignalProxy< void(const std::vector< Block > &)> sigBlocksRequired()
Signal to notify the caller about required blocks, once the blocks are downloaded call cont to contin...
Definition zckhelper.cc:294
static zypp::ByteCount minZchunkDownloadSize()
The minimum size to download to have enough data to know the full header size.
Definition zckhelper.cc:304
Signal< void(const std::vector< Block > &)> _sigBlocksRequired
Definition zckhelper.h:128
std::optional< zypp::ByteCount > _zcKHeaderSize
Definition zckhelper.h:126
zypp::AutoFD _targetFd
Definition zckhelper.h:120
AutoDispose<int> calling close
std::vector< Block > _blocks
Definition zckhelper.h:60
struct zckCtx zckCtx
Definition zckstream.h:18
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:126