libzypp  17.35.8
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 
12 namespace zyppng {
13 
15  public:
16  DownloadSpecPrivate() = default;
19  DownloadSpecPrivate(const DownloadSpecPrivate &other) = default;
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 
40  DownloadSpec::DownloadSpec( Url file , zypp::filesystem::Pathname targetPath, zypp::ByteCount expectedFileSize ) : d_ptr( new DownloadSpecPrivate() )
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 }
DownloadSpec & setHeaderChecksum(const zypp::CheckSum &sum)
Store and operate with byte count.
Definition: ByteCount.h:31
DownloadSpecPrivate & operator=(const DownloadSpecPrivate &)=delete
Holds transfer setting.
zypp::ByteCount _preferred_chunk_size
Definition: downloadspec.cc:35
DownloadSpec & setTransferSettings(TransferSettings &&set)
DownloadSpec & setPreferredChunkSize(const zypp::ByteCount &bc)
TransferSettings _settings
Definition: downloadspec.cc:27
DownloadSpec & setTargetPath(const zypp::Pathname &path)
Definition: downloadspec.cc:64
bool metalinkEnabled() const
Definition: downloadspec.cc:76
zypp::filesystem::Pathname deltaFile() const
Definition: downloadspec.cc:98
DownloadSpec & setExpectedFileSize(const zypp::ByteCount &bc)
DownloadSpec & setDeltaFile(const zypp::Pathname &file)
Definition: downloadspec.cc:92
#define Z_D()
Definition: zyppglobal.h:105
bool checkExistsOnly() const
Definition: downloadspec.cc:87
zypp::ByteCount preferredChunkSize() const
DownloadSpecPrivate * clone() const
Definition: downloadspec.cc:22
const std::optional< zypp::CheckSum > & headerChecksum() const
zypp::RWCOW_pointer< DownloadSpecPrivate > d_ptr
Definition: downloadspec.h:111
DownloadSpec & setUrl(const Url &url)
Definition: downloadspec.cc:53
const zypp::Pathname & targetPath() const
Definition: downloadspec.cc:59
std::optional< zypp::CheckSum > _headerChecksum
Definition: downloadspec.cc:34
zypp::ByteCount expectedFileSize() const
DownloadSpec & setMetalinkEnabled(bool enable=true)
Definition: downloadspec.cc:70
zypp::ByteCount _expectedFileSize
Definition: downloadspec.cc:29
const TransferSettings & settings() const
bool empty() const
Definition: CheckSum.cc:173
ZYPP_IMPL_PRIVATE(UnixSignalSource)
DownloadSpec & setHeaderSize(const zypp::ByteCount &bc)
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
zypp::ByteCount headerSize() const
const Url & url() const
Definition: downloadspec.cc:48
Url manipulation class.
Definition: Url.h:91
DownloadSpec & setCheckExistsOnly(bool set=true)
Definition: downloadspec.cc:81
zypp::ByteCount _headerSize
Definition: downloadspec.cc:33