16#include <zypp-media/ng/ProvideSpec> 
   33    const std::optional<zypp::Pathname> &
rootPath() 
const;
 
   34    MediaSyncFacadeRef 
parent() 
const;
 
   43    void unref_to(
unsigned int) 
const override;
 
 
   75    return _origin.authority().url();
 
 
  103      _parent->releaseMedium ( 
this );
 
 
  117    return _data->parent();
 
 
  122    return _data.get() != 
nullptr;
 
 
  128    if ( !
_data ) 
return invalidHandle;
 
  129    return _data->origin().authority().url();
 
 
  134    static std::optional<zypp::Pathname> invalidPath;
 
  137    return _data->rootPath();
 
 
  159    if ( !handlerType ) {
 
  160      ERR << 
"Authority URL: " << origin.
authority() << 
" is not supported!" << std::endl;
 
  165    for ( 
const auto &mirror : origin.
mirrors() ) {
 
  168        WAR << 
"URL: " << mirror << 
" is not supported, ignoring!" << std::endl;
 
  171      if ( handlerType == *s) {
 
  174        WAR << 
"URL: " << mirror << 
" has different handler type than the authority URL: "<< origin.
authority() <<
", ignoring!" << std::endl;
 
 
  191    if ( !sanitizedOrigin.
isValid() )
 
  195      for ( 
auto &ep : sanitizedOrigin )
 
  201      return medium->isSameMedium( sanitizedOrigin, request );
 
  210    std::optional<zypp::media::MediaAccessId> attachId;
 
  218          attachId = mgr.
open( sanitizedOrigin );
 
  227        auto locPath = mgr.
localPath( *attachId, 
"/" );
 
  254          unsigned int devindex = 0;
 
  256          std::vector<std::string> devices;
 
  259          std::optional<std::string> currentlyUsed;
 
  260          if ( devices.size() ) currentlyUsed = devices[devindex];
 
  265            devices.erase( std::remove_if( devices.begin (), devices.end(), [&](
const std::string &dev) {
 
  266              zypp::PathInfo devInfo(dev);
 
  267              return std::any_of( mountedDevs.begin (), mountedDevs.end(), [&devInfo]( const zypp::media::MountEntry &e ) {
 
  268                zypp::PathInfo pi( e.src );
 
  269                return ( pi.isBlk() && pi.devMajor() == devInfo.devMajor() && pi.devMinor() == devInfo.devMinor() );
 
  273            if ( !devices.size () ) {
 
  275              MIL << 
"No free device available, return jammed and try again later ( hopefully) " << std::endl;
 
  276              if ( attachId ) mgr.
close ( *attachId );
 
  281            bool foundCurrent = 
false;
 
  282            if ( currentlyUsed ) {
 
  283              for ( 
unsigned int i = 0; i < devices.size(); i++ ) {
 
  284                if ( devices[i] == *currentlyUsed ) {
 
  292            if ( !foundCurrent ){
 
  299          user = report->requestMedia (
 
  309          MIL << 
"ProvideFile exception caught, callback answer: " << user << std::endl;
 
  313              DBG << 
"Aborting" << std::endl;
 
  314              if ( attachId ) mgr.
close ( *attachId );
 
  315              zypp::AbortRequestException aexcp(
"Aborting requested by user");
 
  316              aexcp.remember(excp);
 
  320              DBG << 
"Skipping" << std::endl;
 
  321              if ( attachId ) mgr.
close ( *attachId );
 
  322              zypp::SkipRequestException nexcp(
"User-requested skipping of a file");
 
  323              nexcp.remember(excp);
 
  327              DBG << 
"Eject: try to release" << std::endl;
 
  332                mgr.
release (*attachId, devindex < devices.size() ? devices[devindex] : 
"");
 
  343              DBG << 
"Going to try again" << std::endl;
 
  347                mgr.
close(*attachId);
 
  352              if ( sanitizedOrigin.
authority().
url() != effectiveUrl ) {
 
  362              DBG << 
"Don't know, let's ABORT" << std::endl;
 
  363              if ( attachId ) mgr.
close ( *attachId );
 
  370        if ( attachId ) mgr.
close ( *attachId );
 
  374        if ( attachId ) mgr.
close ( *attachId );
 
 
  385      WAR << 
"Releasing zyppng::MediaSyncFacade with still valid MediaHandles, this is a bug!" << std::endl;
 
 
  392    if ( !sanitizedOrigin.isValid() )
 
 
  408    MIL << 
"Attaching lazy medium with label: [" << lazyHandle.
spec().
label() << 
"]" << std::endl;
 
 
  424    std::optional<expected<MediaSyncFacade::Res>> lastErr;
 
  449    url.setPathName (
"/");
 
 
  462    const auto &handleInfo = attachHandle.
info();
 
  466        if ( !mgr.
doesFileExist ( handleInfo.mediaId (), fileName ) ) {
 
  481        if ( handleInfo.url().schemeIsDownloading() )
 
 
  500      auto me = weakMe.lock();
 
  503      return me->provide( handle, fName, req);
 
 
  521      url.setPathName( source );
 
  524      if ( !sourcePi.isExist() ) {
 
  527      if ( !sourcePi.isFile () )
 
 
  563      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.
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
const std::vector< OriginEndpoint > & mirrors() const
void setAuthority(OriginEndpoint newAuthority)
bool addMirror(OriginEndpoint newMirror)
const OriginEndpoint & authority() const
Represents a single, configurable network endpoint, combining a URL with specific access settings.
const zypp::Url & url() const
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.
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_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)