13#include <zypp-core/fs/PathInfo.h>
25 , _blockList(
std::move(blockList) )
27 MIL <<
"About to enter DlMetalinkState for url " << parent.
_spec.
url() << std::endl;
32 auto &sm = stateMachine();
33 const auto &spec = sm._spec;
38 if ( !spec.deltaFile().empty() ) {
40 if ( dFileInfo.
isFile() && dFileInfo.
isR() ) {
41 FILE *f = fopen( spec.targetPath().asString().c_str(),
"w+b" );
53 DBG <<
"Delta XFER: Delta file: " << spec.deltaFile() <<
" does not exist or is not readable." << std::endl;
56 DBG <<
"Delta XFER: No delta file given, can not reuse blocks." << std::endl;
76 zypp::str::Format(
"Metalink file reports a different filesize than what was expected ( Meta: %1% != Exp: %2%).") % fLen %
_fileSize )
83 const auto maxConns = sm._requestDispatcher->maximumConcurrentConnections();
84 if ( sm._spec.preferredChunkSize() == 0 ) {
86 if ( maxConns == -1 ) {
100 MIL <<
"Downloading " << sm._spec.url() <<
" with " <<
_preferredChunkSize <<
" chunk size over " << maxConns << std::endl;
103 size_t bytesToDl = 0;
111 .
start = mediaBlock.off,
112 .len = mediaBlock.size,
114 .chksumVec = blockSum,
115 .chksumCompareLen = blockSum.size( ),
116 .chksumPad = chksumPad > 0 ? chksumPad : std::optional<size_t>()
119 bytesToDl += mediaBlock.size;
140 std::ifstream istrm( stateMachine()._spec.targetPath().asString(), std::ios::binary);
141 if ( !istrm.is_open() ) {
142 setFailed(
"Failed to verify file digest (Could not open target file)." );
145 if ( !dig.
update( istrm ) ) {
146 setFailed(
"Failed to verify file digest (Could not read target file)." );
152 setFailed(
"Failed to verify file digest (Checksum did not match)." );
161 return std::make_shared<FinishedState>( std::move(
_error), stateMachine() );
Store and operate with byte count.
static const Unit M
1024^2 Byte
Compute Message Digests (MD5, SHA1 etc)
UByteArray digestVector()
get vector of unsigned char representation of the digest
bool update(const char *bytes, size_t len)
feed data into digest computation algorithm
bool create(const std::string &name)
initialize creation of a new message digest
Wrapper class for stat/lstat.
static zyppng::NetworkRequestError customError(NetworkRequestError::Type t, std::string &&errorMsg="", std::map< std::string, boost::any > &&extraInfo={})
The NetworkRequestError class Represents a error that occured in.
NetworkRequestError _error
off_t _downloadedMultiByteCount
zypp::ByteCount _preferredChunkSize
virtual void setFinished()
std::list< Block > _ranges
std::list< Block > _failedRanges
static zypp::ByteCount makeBlksize(size_t filesize)
void cancelAll(const NetworkRequestError &err)
void setFailed(NetworkRequestError &&err)
void ensureDownloadsRunning()