libzypp 17.31.23
downloadspec.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------*/
9#include "downloadspec.h"
10#include <string>
11
12namespace zyppng {
13
15 public:
17 DownloadSpecPrivate( const DownloadSpecPrivate &other ) = default;
19
21 return new DownloadSpecPrivate(*this);
22 }
23
29 bool _checkExistanceOnly = false; //< this will NOT download the file, but only query the server if it exists
30 bool _metalink_enabled = true; //< should the download try to use metalinks
31 zypp::ByteCount _headerSize; //< Optional file header size for things like zchunk
32 std::optional<zypp::CheckSum> _headerChecksum; //< Optional file header checksum
34 };
35
37
38 DownloadSpec::DownloadSpec( Url file , zypp::filesystem::Pathname targetPath, zypp::ByteCount expectedFileSize ) : d_ptr( new DownloadSpecPrivate() )
39 {
40 // default settings
41 d_ptr->_url = std::move(file);
42 d_ptr->_targetPath = std::move(targetPath);
43 d_ptr->_expectedFileSize = std::move( expectedFileSize );
44 }
45
46 DownloadSpec::DownloadSpec( const DownloadSpec &other ) = default;
47
48 DownloadSpec &DownloadSpec::operator=(const DownloadSpec &other) = default;
49
50 const Url &DownloadSpec::url() const
51 {
52 return d_ptr->_url;
53 }
54
56 {
57 d_ptr->_url = url;
58 return *this;
59 }
60
62 {
63 return d_ptr->_targetPath;
64 }
65
67 {
68 d_ptr->_targetPath = path;
69 return *this;
70 }
71
73 {
74 d_ptr->_metalink_enabled = enable;
75 return *this;
76 }
77
79 {
80 return d_ptr->_metalink_enabled;
81 }
82
84 {
85 d_ptr->_checkExistanceOnly = ( set );
86 return *this;
87 }
88
90 {
91 return d_ptr->_checkExistanceOnly;
92 }
93
95 {
96 d_ptr->_delta = file;
97 return *this;
98 }
99
101 {
102 return d_ptr->_delta;
103 }
104
106 {
107 d_ptr->_preferred_chunk_size = bc;
108 return *this;
109 }
110
112 {
113 return d_ptr->_preferred_chunk_size;
114 }
115
117 {
118 return d_ptr->_settings;
119 }
120
122 {
123 d_ptr->_settings = std::move( set );
124 return *this;
125 }
126
128 {
129 d_ptr->_settings = set;
130 return *this;
131 }
132
134 {
135 d_ptr->_expectedFileSize = bc;
136 return *this;
137 }
138
140 {
141 return d_ptr->_expectedFileSize;
142 }
143
145 {
146 d_ptr->_headerSize = bc;
147 return *this;
148 }
149
151 {
152 return d_ptr->_headerSize;
153 }
154
155 const std::optional<zypp::CheckSum> &DownloadSpec::headerChecksum() const
156 {
157 Z_D();
158 return d->_headerChecksum;
159 }
160
162 {
163 Z_D();
164 if ( sum.empty() )
165 d->_headerChecksum.reset();
166 else {
167 d->_headerChecksum = sum;
168 }
169 return *this;
170 }
171}
Store and operate with byte count.
Definition: ByteCount.h:31
bool empty() const
Definition: CheckSum.cc:173
Url manipulation class.
Definition: Url.h:92
Holds transfer setting.
zypp::ByteCount _preferred_chunk_size
Definition: downloadspec.cc:33
TransferSettings _settings
Definition: downloadspec.cc:25
std::optional< zypp::CheckSum > _headerChecksum
Definition: downloadspec.cc:32
DownloadSpecPrivate(DownloadSpecPrivate &&other)=default
DownloadSpecPrivate * clone() const
Definition: downloadspec.cc:20
zypp::ByteCount _expectedFileSize
Definition: downloadspec.cc:27
zypp::ByteCount _headerSize
Definition: downloadspec.cc:31
DownloadSpecPrivate(const DownloadSpecPrivate &other)=default
const TransferSettings & settings() const
DownloadSpec & setUrl(const Url &url)
Definition: downloadspec.cc:55
zypp::RWCOW_pointer< DownloadSpecPrivate > d_ptr
Definition: downloadspec.h:109
DownloadSpec(Url file, zypp::filesystem::Pathname targetPath, zypp::ByteCount expectedFileSize=zypp::ByteCount())
Definition: downloadspec.cc:38
zypp::ByteCount preferredChunkSize() const
DownloadSpec & operator=(const DownloadSpec &other)
DownloadSpec & setDeltaFile(const zypp::Pathname &file)
Definition: downloadspec.cc:94
DownloadSpec & setExpectedFileSize(const zypp::ByteCount &bc)
const std::optional< zypp::CheckSum > & headerChecksum() const
DownloadSpec & setCheckExistsOnly(bool set=true)
Definition: downloadspec.cc:83
zypp::ByteCount headerSize() const
zypp::filesystem::Pathname deltaFile() const
DownloadSpec & setHeaderChecksum(const zypp::CheckSum &sum)
DownloadSpec & setHeaderSize(const zypp::ByteCount &bc)
const zypp::Pathname & targetPath() const
Definition: downloadspec.cc:61
const Url & url() const
Definition: downloadspec.cc:50
DownloadSpec & setTransferSettings(TransferSettings &&set)
DownloadSpec & setMetalinkEnabled(bool enable=true)
Definition: downloadspec.cc:72
DownloadSpec & setTargetPath(const zypp::Pathname &path)
Definition: downloadspec.cc:66
zypp::ByteCount expectedFileSize() const
bool metalinkEnabled() const
Definition: downloadspec.cc:78
bool checkExistsOnly() const
Definition: downloadspec.cc:89
DownloadSpec & setPreferredChunkSize(const zypp::ByteCount &bc)
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
ZYPP_IMPL_PRIVATE(Provide)