libzypp 17.35.18
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:
20 DownloadSpecPrivate( DownloadSpecPrivate &&other ) noexcept = default;
21
23 return new DownloadSpecPrivate(*this);
24 }
25
31 bool _checkExistanceOnly = false; //< this will NOT download the file, but only query the server if it exists
32 bool _metalink_enabled = true; //< should the download try to use metalinks
33 zypp::ByteCount _headerSize; //< Optional file header size for things like zchunk
34 std::optional<zypp::CheckSum> _headerChecksum; //< Optional file header checksum
36 };
37
39
41 {
42 // default settings
43 d_ptr->_url = std::move(file);
44 d_ptr->_targetPath = std::move(targetPath);
45 d_ptr->_expectedFileSize = std::move( expectedFileSize );
46 }
47
48 const Url &DownloadSpec::url() const
49 {
50 return d_ptr->_url;
51 }
52
54 {
55 d_ptr->_url = url;
56 return *this;
57 }
58
60 {
61 return d_ptr->_targetPath;
62 }
63
65 {
66 d_ptr->_targetPath = path;
67 return *this;
68 }
69
71 {
72 d_ptr->_metalink_enabled = enable;
73 return *this;
74 }
75
77 {
78 return d_ptr->_metalink_enabled;
79 }
80
82 {
83 d_ptr->_checkExistanceOnly = ( set );
84 return *this;
85 }
86
88 {
89 return d_ptr->_checkExistanceOnly;
90 }
91
93 {
94 d_ptr->_delta = file;
95 return *this;
96 }
97
99 {
100 return d_ptr->_delta;
101 }
102
104 {
105 d_ptr->_preferred_chunk_size = bc;
106 return *this;
107 }
108
110 {
111 return d_ptr->_preferred_chunk_size;
112 }
113
115 {
116 return d_ptr->_settings;
117 }
118
120 {
121 d_ptr->_settings = std::move( set );
122 return *this;
123 }
124
126 {
127 d_ptr->_settings = set;
128 return *this;
129 }
130
132 {
133 d_ptr->_expectedFileSize = bc;
134 return *this;
135 }
136
138 {
139 return d_ptr->_expectedFileSize;
140 }
141
143 {
144 d_ptr->_headerSize = bc;
145 return *this;
146 }
147
149 {
150 return d_ptr->_headerSize;
151 }
152
153 const std::optional<zypp::CheckSum> &DownloadSpec::headerChecksum() const
154 {
155 Z_D();
156 return d->_headerChecksum;
157 }
158
160 {
161 Z_D();
162 if ( sum.empty() )
163 d->_headerChecksum.reset();
164 else {
165 d->_headerChecksum = sum;
166 }
167 return *this;
168 }
169}
Store and operate with byte count.
Definition ByteCount.h:32
bool empty() const
Definition CheckSum.cc:173
Url manipulation class.
Definition Url.h:93
zypp::ByteCount _preferred_chunk_size
DownloadSpecPrivate & operator=(DownloadSpecPrivate &&)=delete
std::optional< zypp::CheckSum > _headerChecksum
DownloadSpecPrivate * clone() const
DownloadSpecPrivate(DownloadSpecPrivate &&other) noexcept=default
zypp::ByteCount _expectedFileSize
DownloadSpecPrivate & operator=(const DownloadSpecPrivate &)=delete
DownloadSpecPrivate(const DownloadSpecPrivate &other)=default
const TransferSettings & settings() const
DownloadSpec & setUrl(const Url &url)
zypp::RWCOW_pointer< DownloadSpecPrivate > d_ptr
DownloadSpec(Url file, zypp::filesystem::Pathname targetPath, zypp::ByteCount expectedFileSize=zypp::ByteCount())
zypp::ByteCount preferredChunkSize() const
DownloadSpec & setDeltaFile(const zypp::Pathname &file)
DownloadSpec & setExpectedFileSize(const zypp::ByteCount &bc)
const std::optional< zypp::CheckSum > & headerChecksum() const
DownloadSpec & setCheckExistsOnly(bool set=true)
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
const Url & url() const
DownloadSpec & setTransferSettings(TransferSettings &&set)
DownloadSpec & setMetalinkEnabled(bool enable=true)
DownloadSpec & setTargetPath(const zypp::Pathname &path)
zypp::ByteCount expectedFileSize() const
bool metalinkEnabled() const
bool checkExistsOnly() const
DownloadSpec & setPreferredChunkSize(const zypp::ByteCount &bc)
Types and functions for filesystem operations.
Definition Glob.cc:24
Easy-to use interface to the ZYPP dependency resolver.
zypp::media::TransferSettings TransferSettings
Definition downloader.h:25
#define ZYPP_IMPL_PRIVATE(Class)
Definition zyppglobal.h:92
#define Z_D()
Definition zyppglobal.h:105