15#include <zypp-media/ng/ProvideSpec>
31 const std::optional<zypp::Pathname> &
rootPath()
const;
32 MediaSyncFacadeRef
parent()
const;
41 void unref_to(
unsigned int)
const override;
55 , _attachedUrl(
std::move( baseUrl ))
89 if ( !zypp::indeterminate (check) )
93 return ( std::find( urls.begin(), urls.end(),
_attachedUrl ) != urls.end() );
101 _parent->releaseMedium (
this );
115 return _data->parent();
120 return _data.get() !=
nullptr;
136 return _data->rootPath();
145 : _res(
std::move(file) )
146 , _provideHandle(
std::move (
hdl) )
158 std::optional<zypp::media::MediaHandlerFactory::MediaHandlerType> handlerType;
163 WAR <<
"URL: " << *
mirrIt <<
" is not supported, ignoring!" << std::endl;
166 if ( !handlerType ) {
170 if ( handlerType == *
s) {
173 WAR <<
"URL: " << *
mirrIt <<
" has different handler type than the primary URL: "<<
usableMirrs.front() <<
", ignoring!" << std::endl;
192 std::optional<zypp::media::MediaAccessId>
attachId;
205 if ( !
request.mediaFile().empty() ) {
242 std::vector<std::string>
devices;
252 zypp::PathInfo devInfo(dev);
253 return std::any_of( mountedDevs.begin (), mountedDevs.end(), [&devInfo]( const zypp::media::MountEntry &e ) {
254 zypp::PathInfo pi( e.src );
255 return ( pi.isBlk() && pi.devMajor() == devInfo.devMajor() && pi.devMinor() == devInfo.devMinor() );
261 MIL <<
"No free device available, return jammed and try again later ( hopefully) " << std::endl;
269 for (
unsigned int i = 0;
i <
devices.size();
i++ ) {
283 user = report->requestMedia (
288 excp.asUserHistory(),
293 MIL <<
"ProvideFile exception caught, callback answer: " << user << std::endl;
297 DBG <<
"Aborting" << std::endl;
304 DBG <<
"Skipping" << std::endl;
311 DBG <<
"Eject: try to release" << std::endl;
327 DBG <<
"Going to try again" << std::endl;
340 DBG <<
"Don't know, let's ABORT" << std::endl;
368 return medium->isSameMedium( useableUrls, request );
376 std::exception_ptr lastError;
393 lastError = std::current_exception();
396 lastError = std::current_exception();
404 }
else if ( lastError ) {
416 if ( _attachedMedia.size () ) {
417 WAR <<
"Releasing zyppng::MediaSyncFacade with still valid MediaHandles, this is a bug!" << std::endl;
440 MIL <<
"Attaching lazy medium with label: [" <<
lazyHandle.spec().label() <<
"]" << std::endl;
444 lazyHandle._sharedData->_mediaHandle = handle;
456 std::optional<expected<MediaSyncFacade::Res>>
lastErr;
497 if (
request.checkExistsOnly() ) {
535 return me->provide( handle,
fName, req);
583 auto i = std::find_if(_attachedMedia.begin (), _attachedMedia.end(), [&](
const auto &
p ) { return p.get() == ptr; } );
587 mgr.close (
ptr->mediaId() );
592 if (
i != _attachedMedia.end() ) {
593 _attachedMedia.erase(
i);
595 ERR <<
"Releasing unknown medium " <<
ptr->mediaId () <<
" should not happen";
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void reset()
Reset to default Ctor values.
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
Base class for Exception.
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
void setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
static bool schemeIsVolatile(const std::string &scheme_r)
cd dvd
Base class for reference counted objects.
Wrapper class for stat/lstat.
const std::string & asString() const
String representation.
static expected success(ConsParams &&...params)
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
int unlink(const Pathname &path)
Like 'unlink'.
ResultType and_then(const expected< T, E > &exp, Function &&f)
Wrapper for const correct access via Smart pointer types.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_FWD_EXCPT(EXCPT)
Drops a logline and returns the given Exception as a std::exception_ptr.
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
#define ZYPP_FWD_CURRENT_EXCPT()
Drops a logline and returns the current Exception as a std::exception_ptr.
#define IMPL_PTR_TYPE(NAME)
#define ZYPP_IMPL_PRIVATE_CONSTR(Class)