24 , _request(
std::move(req) )
31 MIL_MEDIA <<
"Reusing request from previous state" << std::endl;
35 _request->setTargetFilePath( spec.targetPath() );
62 auto url = sm._spec.url();
63 auto set = sm._spec.settings();
66 if ( err.isError() ) {
67 WAR <<
"Setting up mirror " << mirror.second->mirrorUrl <<
" failed with error: " << err.toString() <<
"(" << err.nativeErrorString() <<
"), falling back to original URL." << std::endl;
81 const auto &spec = sm._spec;
84 _request->_myMirror = std::move(mirror);
94 const auto &spec = sm._spec;
96 auto url = spec.url();
97 auto set = spec.settings();
98 auto err = sm.safeFillSettingsFromURL( url, set );
100 return failed( std::move(err) );
109 return failed(
"Request was not intialized before starting it.");
112 std::optional<zypp::Digest> fileDigest =
zypp::Digest();
118 if ( sm._spec.checkExistsOnly() )
122 return failed(
"Failed to initialize request" );
127 _request->setPriority( sm._defaultSubRequestPriority );
131 sm._requestDispatcher->enqueue(
_request );
151 _error = std::move( err );
160 if ( !sm._emittedSigStart ) {
161 sm._emittedSigStart =
true;
165 _request->_myMirror->startTransfer();
171 const off_t expFSize = sm._spec.expectedFileSize();
176 return sm._sigProgress.emit( *sm.z_func(), (expFSize > 0 ? expFSize : dltotal), dlnow );
194 if ( sm.handleRequestAuthError(
_request, err ) ) {
196 _request->setPriority( sm._defaultSubRequestPriority );
197 sm._requestDispatcher->enqueue(
_request );
Compute Message Digests (MD5, SHA1 etc)
DownloadPrivate & stateMachine()
Signal< void(Download &req)> _sigStarted
const TransferSettings & settings() const
std::pair< std::vector< Url >::const_iterator, MirrorHandle > MirrorPick
std::shared_ptr< Mirror > MirrorHandle
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.
std::string toString() const
toString Returns a string representation of the error
std::string nativeErrorString() const
bool isError() const
isError Will return true if this is a actual error
zypp::ByteCount downloadedByteCount() const
Returns the number of already downloaded bytes as reported by the backend.
bool hasError() const
Checks if there was a error with the request.
void * nativeHandle() const
const std::string & lastRedirectInfo() const
Url clearQueryString(const Url &url)
String related utilities and Regular expression matching.
int unlink(const Pathname &path)
Like 'unlink'.
std::optional< UByteArray > _chksumVec
virtual void handleRequestProgress(NetworkRequest &req, off_t dltotal, off_t dlnow)
void startWithoutMirror()
std::optional< std::string > _chksumtype
void failedToPrepare() override
virtual void gotFinished()
NetworkRequestError _error
void onRequestProgress(NetworkRequest &, off_t dltotal, off_t dlnow, off_t, off_t)
void onRequestFinished(NetworkRequest &req, const NetworkRequestError &err)
std::shared_ptr< Request > _request
virtual void failed(NetworkRequestError &&err)
void startWithMirror(MirrorControl::MirrorHandle mirror, const zypp::Url &url, const TransferSettings &set)
BasicDownloaderStateBase(DownloadPrivate &parent)
void mirrorReceived(MirrorControl::MirrorPick mirror) override
virtual bool initializeRequest(std::shared_ptr< Request > &r)
Signal< void() > _sigFailed
void onRequestStarted(NetworkRequest &)
Signal< void() > _sigFinished
NetworkRequestError setupMirror(const MirrorControl::MirrorPick &pick, Url &url, TransferSettings &set)
std::vector< Url > _fileMirrors
PrepareResult prepareNextMirror()