11 #include <zypp-media/ng/MediaVerifier> 12 #include <zypp-core/fs/PathInfo.h> 14 #undef ZYPP_BASE_LOGGER_LOGGROUP 15 #define ZYPP_BASE_LOGGER_LOGGROUP "MountingWorker" 32 return _driver->initialize(conf);
43 auto req = queue.front();
46 MIL_PRV <<
"Received provide: " << req->_spec.code() << std::endl;
49 switch ( req->_spec.code () ) {
50 case zyppng::ProvideMessage::Code::Attach: {
56 req ->_spec.forEachVal([&](
const std::string &name,
const auto &val ) {
61 vals.
add( name, val );
65 const auto &res =
_driver->mountDevice( req->_spec.requestId(), attachUrl, attachId, label, vals );
67 const auto &err = res.error();
77 MIL <<
"Attach of " << attachUrl <<
" was successfull" << std::endl;
81 case zyppng::ProvideMessage::Code::Detach: {
86 if (
_driver->detachMedia( attachId ) ) {
90 , zyppng::ProvideMessage::Code::NotFound
91 ,
"Attach ID not known." 101 case zyppng::ProvideMessage::Code::Provide: {
106 const auto &availMedia =
_driver->attachedMedia();
108 auto i = availMedia.find( attachId );
109 if ( i == availMedia.end() ) {
110 ERR <<
"Unknown Attach ID " << attachId << std::endl;
112 , zyppng::ProvideMessage::Code::NotFound
113 ,
"Attach ID not known." 119 const auto &locPath = i->second._dev->_mountPoint / i->second._attachRoot / path;
121 MIL <<
"Trying to find file: " << locPath << std::endl;
131 , zyppng::ProvideMessage::Code::NotAFile
132 ,
zypp::str::Str() <<
"Path " << path <<
" exists, but its not a file" 137 , zyppng::ProvideMessage::Code::NotFound
148 , zyppng::ProvideMessage::Code::BadRequest
149 ,
"Request type not implemented" 158 , zyppng::ProvideMessage::Code::BadRequest
163 }
catch (
const std::exception &e ) {
166 , zyppng::ProvideMessage::Code::BadRequest
174 , zyppng::ProvideMessage::Code::BadRequest
175 ,
"Unknown exception" 184 ERR <<
"Bug, cancel should never be called for running items" << std::endl;
constexpr std::string_view AttachId("attach_id")
void immediateShutdown() override
void attachSuccess(const uint32_t id)
void provideFailed(const uint32_t id, const uint code, const std::string &reason, const bool transient, const HeaderValueMap extra={})
zyppng::expected< zyppng::worker::WorkerCaps > initialize(const zyppng::worker::Configuration &conf) override
std::string asString() const
Returns a default string representation of the Url object.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
bool isExist() const
Return whether valid stat info exists.
std::string asString() const
Error message provided by dumpOn as string.
constexpr std::string_view Label("label")
std::string getAuthority() const
Returns the encoded authority component of the URL.
std::deque< ProvideWorkerItemRef > & requestQueue()
Base class for Exception.
constexpr std::string_view Url("url")
constexpr std::string_view Url("url")
void cancel(const std::deque< zyppng::worker::ProvideWorkerItemRef >::iterator &i) override
MountingWorker(std::string_view workerName, DeviceDriverRef driver)
Wrapper class for ::stat/::lstat.
void detachSuccess(const uint32_t id)
zypp::proto::Configuration Configuration
void provideSuccess(const uint32_t id, bool cacheHit, const zypp::Pathname &localFile, const HeaderValueMap extra={})