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;
 
 
   88    const auto check = 
_spec.isSameMedium(
spec);
 
   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;
 
 
  127      return invalidHandle;
 
 
  133    static std::optional<zypp::Pathname> invalidPath;
 
  136    return _data->rootPath();
 
 
  157    std::vector<zypp::Url> usableMirrs;
 
  158    std::optional<zypp::media::MediaHandlerFactory::MediaHandlerType> handlerType;
 
  160    for ( 
auto mirrIt = urls.begin() ; mirrIt != urls.end(); mirrIt++ ) {
 
  163        WAR << 
"URL: " << *mirrIt << 
" is not supported, ignoring!" << std::endl;
 
  166      if ( !handlerType ) {
 
  168        usableMirrs.push_back ( *mirrIt );
 
  170        if ( handlerType == *s) {
 
  171          usableMirrs.push_back( *mirrIt );
 
  173          WAR << 
"URL: " << *mirrIt << 
" has different handler type than the primary URL: "<< usableMirrs.front() <<
", ignoring!" << std::endl;
 
  178    if ( !handlerType || usableMirrs.empty() ) {
 
 
  188    bool isVolatile = 
url.schemeIsVolatile();
 
  190    auto effectiveUrl = 
url;
 
  192    std::optional<zypp::media::MediaAccessId> attachId;
 
  204          attachId = mgr.
open( effectiveUrl );
 
  213        auto locPath = mgr.
localPath( *attachId, 
"/" );
 
  240          unsigned int devindex = 0;
 
  242          std::vector<std::string> devices;
 
  245          std::optional<std::string> currentlyUsed;
 
  246          if ( devices.size() ) currentlyUsed = devices[devindex];
 
  251            devices.erase( std::remove_if( devices.begin (), devices.end(), [&](
const std::string &dev) {
 
  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() );
 
  259            if ( !devices.size () ) {
 
  261              MIL << 
"No free device available, return jammed and try again later ( hopefully) " << std::endl;
 
  262              if ( attachId ) mgr.
close ( *attachId );
 
  267            bool foundCurrent = 
false;
 
  268            if ( currentlyUsed ) {
 
  269              for ( 
unsigned int i = 0; i < devices.size(); i++ ) {
 
  270                if ( devices[i] == *currentlyUsed ) {
 
  278            if ( !foundCurrent ){
 
  283          user = report->requestMedia (
 
  293          MIL << 
"ProvideFile exception caught, callback answer: " << user << std::endl;
 
  297              DBG << 
"Aborting" << std::endl;
 
  298              if ( attachId ) mgr.
close ( *attachId );
 
  299              zypp::AbortRequestException aexcp(
"Aborting requested by user");
 
  300              aexcp.remember(excp);
 
  304              DBG << 
"Skipping" << std::endl;
 
  305              if ( attachId ) mgr.
close ( *attachId );
 
  306              zypp::SkipRequestException nexcp(
"User-requested skipping of a file");
 
  307              nexcp.remember(excp);
 
  311              DBG << 
"Eject: try to release" << std::endl;
 
  316                mgr.
release (*attachId, devindex < devices.size() ? devices[devindex] : 
"");
 
  327              DBG << 
"Going to try again" << std::endl;
 
  331                mgr.
close(*attachId);
 
  340              DBG << 
"Don't know, let's ABORT" << std::endl;
 
  341              if ( attachId ) mgr.
close ( *attachId );
 
  348        if ( attachId ) mgr.
close ( *attachId );
 
  352        if ( attachId ) mgr.
close ( *attachId );
 
 
  361    std::vector<zypp::Url> useableUrls = 
sanitizeUrls(urls);
 
  363    if ( useableUrls.empty () )
 
  368      return medium->isSameMedium( useableUrls, request );
 
  376    std::exception_ptr lastError;
 
  377    std::exception_ptr jammedError;
 
  385    for ( 
const auto &
url : useableUrls ) {
 
  390        if ( !jammedError ) jammedError = std::current_exception ();
 
  393        lastError = std::current_exception();
 
  396        lastError = std::current_exception();
 
  404    } 
else if ( lastError ) {
 
 
  417      WAR << 
"Releasing zyppng::MediaSyncFacade with still valid MediaHandles, this is a bug!" << std::endl;
 
 
  424    if ( useableUrls.empty () )
 
 
  440    MIL << 
"Attaching lazy medium with label: [" << lazyHandle.
spec().
label() << 
"]" << std::endl;
 
 
  456    std::optional<expected<MediaSyncFacade::Res>> lastErr;
 
  457    for ( 
const zypp::Url& file_url : urls ) {
 
  461      url.setPathName (
"/");
 
  481    url.setPathName (
"/");
 
 
  488    return provide( std::vector<zypp::Url>{
url}, request );
 
 
  494    const auto &handleInfo = attachHandle.
info();
 
  498        if ( !mgr.
doesFileExist ( handleInfo.mediaId (), fileName ) ) {
 
  513        if ( handleInfo.url().schemeIsDownloading() )
 
 
  532      auto me = weakMe.lock();
 
  535      return me->provide( handle, fName, req);
 
 
  553      url.setPathName( source );
 
  556      if ( !sourcePi.isExist() ) {
 
  559      if ( !sourcePi.isFile () )
 
 
  595      ERR << 
"Releasing unknown medium " << ptr->
mediaId () << 
" should not happen";
 
 
void setDispose(const Dispose &dispose_r)
Set a new dispose function.
Base class for Exception.
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
Base class for reference counted objects.
Wrapper class for stat/lstat.
bool empty() const
Test for an empty path.
std::shared_ptr< T > shared_this() const
std::weak_ptr< T > weak_this() const
zypp::OnMediaLocation asOnMediaLocation(const zypp::Pathname &path, unsigned int mediaNr) const
bool checkExistsOnly() const
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'.
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
ResultType and_then(const expected< T, E > &exp, Function &&f)
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)