14#include <zypp-core/fs/PathInfo.h>
22 , _request(
std::move(req) )
28 const auto &spec = stateMachine()._spec;
29 MIL_MEDIA <<
"Reusing request from previous state" << std::endl;
33 _request->setTargetFilePath( spec.targetPath() );
35 _request->transferSettings() = spec.settings();
59 auto &sm = stateMachine();
60 auto url = sm._spec.url();
61 auto set = sm._spec.settings();
64 if ( err.isError() ) {
65 WAR <<
"Setting up mirror " << mirror.second->mirrorUrl <<
" failed with error: " << err.toString() <<
"(" << err.nativeErrorString() <<
"), falling back to original URL." << std::endl;
78 auto &sm = stateMachine();
79 const auto &spec = sm._spec;
91 auto &sm = stateMachine();
92 const auto &spec = sm._spec;
94 auto url = spec.url();
95 auto set = spec.settings();
96 auto err = sm.safeFillSettingsFromURL( url, set );
98 return failed( std::move(err) );
104 auto &sm = stateMachine();
107 return failed(
"Request was not intialized before starting it.");
110 std::shared_ptr<zypp::Digest> fileDigest = std::make_shared<zypp::Digest>();
116 if ( sm._spec.checkExistsOnly() )
120 return failed(
"Failed to initialize request" );
125 _request->setPriority( sm._defaultSubRequestPriority );
129 sm._requestDispatcher->enqueue(
_request );
149 _error = std::move( err );
157 auto &sm = stateMachine();
158 if ( !sm._emittedSigStart ) {
159 sm._emittedSigStart =
true;
160 stateMachine()._sigStarted.emit( *stateMachine().z_func() );
163 _request->_myMirror->startTransfer();
168 auto &sm = stateMachine();
169 const off_t expFSize = sm._spec.expectedFileSize();
174 return sm._sigProgress.emit( *sm.z_func(), (expFSize > 0 ? expFSize : dltotal), dlnow );
184 auto lck = stateMachine().z_func()->shared_from_this();
185 auto &sm = stateMachine();
192 if ( sm.handleRequestAuthError(
_request, err ) ) {
194 _request->setPriority( sm._defaultSubRequestPriority );
195 sm._requestDispatcher->enqueue(
_request );
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()