#include "zypp/media/MediaDISK.h"
#include "zypp/media/MediaCIFS.h"
#include "zypp/media/MediaCurl.h"
-#include "zypp/media/MediaAria2c.h"
#include "zypp/media/MediaMultiCurl.h"
#include "zypp/media/MediaISO.h"
#include "zypp/media/MediaPlugin.h"
UrlResolverPlugin::HeaderList custom_headers;
Url url = UrlResolverPlugin::resolveUrl(o_url, custom_headers);
-
+
std::string scheme = url.getScheme();
MIL << "Trying scheme '" << scheme << "'" << endl;
_handler = new MediaDISK (url,preferred_attach_point);
else if (scheme == "cifs" || scheme == "smb")
_handler = new MediaCIFS (url,preferred_attach_point);
- else if (scheme == "ftp" || scheme == "http" || scheme == "https")
+ else if (scheme == "ftp" || scheme == "tftp" || scheme == "http" || scheme == "https")
{
- // Another good idea would be activate MediaAria2c handler via external var
- bool use_aria = false;
bool use_multicurl = true;
string urlmediahandler ( url.getQueryParam("mediahandler") );
if ( urlmediahandler == "multicurl" )
{
- use_aria = false;
use_multicurl = true;
}
- else if ( urlmediahandler == "aria2c" )
- {
- use_aria = true;
- use_multicurl = false;
- }
else if ( urlmediahandler == "curl" )
{
- use_aria = false;
use_multicurl = false;
}
else
{
- if ( urlmediahandler.empty() )
+ if ( ! urlmediahandler.empty() )
{
WAR << "unknown mediahandler set: " << urlmediahandler << endl;
}
- const char *ariaenv = getenv( "ZYPP_ARIA2C" );
const char *multicurlenv = getenv( "ZYPP_MULTICURL" );
// if user disabled it manually
if ( use_multicurl && multicurlenv && ( strcmp(multicurlenv, "0" ) == 0 ) )
WAR << "multicurl manually enabled." << endl;
use_multicurl = true;
}
- // if user disabled it manually
- if ( use_aria && ariaenv && ( strcmp(ariaenv, "0" ) == 0 ) )
- {
- WAR << "aria2c manually disabled. Falling back to curl" << endl;
- use_aria = false;
- }
- else if ( !use_aria && ariaenv && ( strcmp(ariaenv, "1" ) == 0 ) )
- {
- // no aria for ftp - no advantage in that over curl
- if ( url.getScheme() == "ftp" )
- WAR << "no aria2c for FTP, despite ZYPP_ARIA2C=1" << endl;
- else
- {
- WAR << "aria2c manually enabled." << endl;
- use_aria = true;
- }
- }
- }
-
- // disable if it does not exist
- if ( use_aria && ! MediaAria2c::existsAria2cmd() )
- {
- WAR << "aria2c not found. Falling back to curl" << endl;
- use_aria = false;
}
- MediaCurl *curl;
+ MediaCurl *curl;
- if ( use_aria )
- curl = new MediaAria2c (url,preferred_attach_point);
- else if ( use_multicurl )
- curl = new MediaMultiCurl (url,preferred_attach_point);
+ if ( use_multicurl )
+ curl = new MediaMultiCurl (url,preferred_attach_point);
else
curl = new MediaCurl (url,preferred_attach_point);
-
- UrlResolverPlugin::HeaderList::const_iterator it;
- for (it = custom_headers.begin();
- it != custom_headers.end();
- ++it) {
- std::string header = it->first + ": " + it->second;
+
+ for ( const auto & el : custom_headers ) {
+ std::string header { el.first };
+ header += ": ";
+ header += el.second;
MIL << "Added custom header -> " << header << endl;
- curl->settings().addHeader(header);
+ curl->settings().addHeader( std::move(header) );
}
- _handler = curl;
+ _handler = curl;
}
else if (scheme == "plugin" )
_handler = new MediaPlugin (url,preferred_attach_point);
// filename is interpreted relative to the attached url
// and a path prefix is preserved to destination
void
-MediaAccess::provideFile( const Pathname & filename ) const
+MediaAccess::provideFile(const Pathname & filename , const ByteCount &expectedFileSize) const
{
if ( !_handler ) {
ZYPP_THROW(MediaNotOpenException("provideFile(" + filename.asString() + ")"));
}
- _handler->provideFile( filename );
+ _handler->provideFile( filename, expectedFileSize );
}
void
try {
media.open( u );
media.attach();
- media._handler->provideFileCopy( base, to );
+ media._handler->provideFileCopy( base, to, 0 );
media.release();
}
catch (const MediaException & excpt_r)