libzypp 17.37.17
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/zyppng/base/Base>
22
23extern "C" {
24 typedef struct zckCtx zckCtx;
25}
26
27namespace zyppng {
28
30 {
31 public:
32 ZckError( const std::string & msg_r );
33 ZckError( std::string && msg_r );
34 };
35
36 class ZckLoader : public Base {
37 public:
38
46
48
50 enum Code {
51 Error, // we got an error
52 NothingToDo, // Target file is already complete
53 ExceedsMaxLen, // Zchunk header reports a different filesize than what was expected
54 Success // Returns a list of blocks to fetch
55 };
56
58 std::vector<Block> _blocks;
60 std::string _message;
61 };
62
63
68 expected<void> buildZchunkFile( const zypp::Pathname &target, const zypp::Pathname &delta, const std::optional<zypp::ByteCount> &expectedFileSize, const std::optional<zypp::ByteCount> &zcKHeaderSize );
69
75
79 void setFailed( const std::string &msg );
80
85 SignalProxy<void(const std::vector<Block> &)> sigBlocksRequired();
86
91
92
97
101 static bool isZchunkFile(const zypp::Pathname &file);
102
107 static PrepareResult prepareZck ( const zypp::Pathname &delta, const zypp::Pathname &target, const zypp::ByteCount &expectedFileSize );
108
112 static bool validateZckFile( const zypp::Pathname &file, std::string &error );
113
114
115 private:
120
123 std::optional<zypp::ByteCount> _expectedFileSize;
124 std::optional<zypp::ByteCount> _zcKHeaderSize;
125
126 Signal<void(const std::vector<Block> &)> _sigBlocksRequired;
128 };
129}
130#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:123
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:127
zypp::Pathname _delta
Definition zckhelper.h:122
zypp::ByteCount _bytesReused
Definition zckhelper.h:119
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:117
RangeDesc Block
Definition zckhelper.h:47
zypp::Pathname _target
Definition zckhelper.h:121
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:126
std::optional< zypp::ByteCount > _zcKHeaderSize
Definition zckhelper.h:124
zypp::AutoFD _targetFd
Definition zckhelper.h:118
AutoDispose<int> calling close
std::vector< Block > _blocks
Definition zckhelper.h:58
struct zckCtx zckCtx
Definition zckstream.h:18