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: {
84 const auto &attachId = url.getAuthority();
86 if (
_driver->detachMedia( attachId ) ) {
90 , zyppng::ProvideMessage::Code::NotFound
91 ,
"Attach ID not known."
101 case zyppng::ProvideMessage::Code::Provide: {
104 const auto &attachId = url.getAuthority();
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;
Base class for Exception.
std::string asString() const
Error message provided by dumpOn as string.
virtual const char * what() const
Return message string.
Wrapper class for stat/lstat.
bool isExist() const
Return whether valid stat info exists.
MountingWorker(std::string_view workerName, DeviceDriverRef driver)
zyppng::expected< zyppng::worker::WorkerCaps > initialize(const zyppng::worker::Configuration &conf) override
void cancel(const std::deque< zyppng::worker::ProvideWorkerItemRef >::iterator &i) override
void immediateShutdown() override
void detachSuccess(const uint32_t id)
void attachSuccess(const uint32_t id)
void provideSuccess(const uint32_t id, bool cacheHit, const zypp::Pathname &localFile, const HeaderValueMap extra={})
void provideFailed(const uint32_t id, const uint code, const std::string &reason, const bool transient, const HeaderValueMap extra={})
std::deque< ProvideWorkerItemRef > & requestQueue()
constexpr std::string_view AttachId("attach_id")
constexpr std::string_view Label("label")
constexpr std::string_view Url("url")
constexpr std::string_view Url("url")
zypp::proto::Configuration Configuration
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...