{
try
{
- release();
+ media::MediaManager manager;
+ for ( const auto & mm : _medias )
+ manager.close( mm.second );
}
catch(...) {} // don't let exception escape a dtor.
}
media_mgr.addVerifier( id, verifier );
// remove any saved verifier for this media
_verifiers.erase(media_nr);
- //if (! noattach && ! media_mgr.isAttached(id))
- //media_mgr.attach(id);
}
else
{
}
}
-// callback::SendReport<source::DownloadFileReport> report;
-// DownloadProgressFileReceiver download_report( report );
-// SourceFactory source_factory;
-// Url file_url( url().asString() + file_r.asString() );
-// report->start( source_factory.createFrom(this), file_url );
-// callback::TempConnect<media::DownloadProgressReport> tmp_download( download_report );
-// Pathname file = provideJustFile( file_r, media_nr, cached, checkonly );
-// report->finish( file_url, source::DownloadFileReport::NO_ERROR, "" );
-// return file;
-
void MediaSetAccess::releaseFile( const OnMediaLocation & on_media_file )
{
releaseFile( on_media_file.filename(), on_media_file.medianr() );
// try to attach the media
if ( ! media_mgr.isAttached(media) )
- media_mgr.attachDesiredMedia(media);
+ media_mgr.attach(media);
media_mgr.dirInfo(media, retlist, dirname, dots);
}
struct ProvideFileOperation
{
Pathname result;
+ ByteCount expectedFileSize;
void operator()( media::MediaAccessId media, const Pathname &file )
{
media::MediaManager media_mgr;
- media_mgr.provideFile(media, file);
+ media_mgr.provideFile(media, file, expectedFileSize);
result = media_mgr.localPath(media, file);
}
};
-
+
struct ProvideDirTreeOperation
{
Pathname result;
struct ProvideFileExistenceOperation
{
bool result;
- ProvideFileExistenceOperation()
- : result(false)
+ ProvideFileExistenceOperation()
+ : result(false)
{}
-
+
void operator()( media::MediaAccessId media, const Pathname &file )
{
media::MediaManager media_mgr;
result = media_mgr.doesFileExist(media, file);
- }
+ }
};
- Pathname MediaSetAccess::provideFile( const OnMediaLocation & resource, ProvideFileOptions options )
+ Pathname MediaSetAccess::provideFile( const OnMediaLocation & resource, ProvideFileOptions options, const Pathname &deltafile )
{
ProvideFileOperation op;
- provide( boost::ref(op), resource, options );
+ op.expectedFileSize = resource.downloadSize();
+ provide( boost::ref(op), resource, options, deltafile );
return op.result;
}
OnMediaLocation resource;
ProvideFileOperation op;
resource.setLocation(file, media_nr);
- provide( boost::ref(op), resource, options );
+ provide( boost::ref(op), resource, options, Pathname() );
return op.result;
}
- Pathname MediaSetAccess::provideOptionalFile(const Pathname & file, unsigned media_nr )
- {
- OnMediaLocation resource;
- ProvideFileOperation op;
- resource.setLocation(file, media_nr);
- try {
- provide(boost::ref(op), resource, PROVIDE_NON_INTERACTIVE);
- }
- catch ( const Exception &e )
- {
- ZYPP_CAUGHT(e);
- }
- return op.result;
- }
-
-
bool MediaSetAccess::doesFileExist(const Pathname & file, unsigned media_nr )
{
ProvideFileExistenceOperation op;
OnMediaLocation resource;
resource.setLocation(file, media_nr);
- provide( boost::ref(op), resource, PROVIDE_DEFAULT);
+ provide( boost::ref(op), resource, PROVIDE_DEFAULT, Pathname());
return op.result;
}
void MediaSetAccess::provide( ProvideOperation op,
const OnMediaLocation &resource,
- ProvideFileOptions options )
+ ProvideFileOptions options,
+ const Pathname &deltafile )
{
Pathname file(resource.filename());
unsigned media_nr(resource.medianr());
-
+
callback::SendReport<media::MediaChangeReport> report;
media::MediaManager media_mgr;
{
// get the mediaId, but don't try to attach it here
media = getMediaAccessId( media_nr);
+ bool deltafileset = false;
try
{
<< " from media number " << media_nr << endl;
// try to attach the media
if ( ! media_mgr.isAttached(media) )
- media_mgr.attachDesiredMedia(media);
+ media_mgr.attach(media);
+ media_mgr.setDeltafile(media, deltafile);
+ deltafileset = true;
op(media, file);
+ media_mgr.setDeltafile(media, Pathname());
break;
}
catch ( media::MediaException & excp )
{
ZYPP_CAUGHT(excp);
+ if (deltafileset)
+ media_mgr.setDeltafile(media, Pathname());
media::MediaChangeReport::Action user = media::MediaChangeReport::ABORT;
unsigned int devindex = 0;
vector<string> devices;
reason = media::MediaChangeReport::IO_SOFT;
}
- // non interactive only bother the user if wrong medium is in the drive
- // otherwise propagate the error
- if ( ( options & PROVIDE_NON_INTERACTIVE ) && reason != media::MediaChangeReport::WRONG)
+ // Propagate the original error if _no_ callback receiver is connected, or
+ // non_interactive mode (for optional files) is used (except for wrong media).
+ if ( ! callback::SendReport<media::MediaChangeReport>::connected()
+ || (( options & PROVIDE_NON_INTERACTIVE ) && reason != media::MediaChangeReport::WRONG ) )
{
MIL << "Can't provide file. Non-Interactive mode." << endl;
ZYPP_RETHROW(excp);
if( user == media::MediaChangeReport::ABORT )
{
DBG << "Aborting" << endl;
- ZYPP_RETHROW ( excp );
+ AbortRequestException aexcp("Aborting requested by user");
+ aexcp.remember(excp);
+ ZYPP_THROW(aexcp);
}
else if ( user == media::MediaChangeReport::IGNORE )
{
else if ( user == media::MediaChangeReport::EJECT )
{
DBG << "Eject: try to release" << endl;
- media_mgr.releaseAll();
- // eject
- media_mgr.release (media,
- devindex < devices.size() ? devices[devindex] : "");
+ try
+ {
+ media_mgr.releaseAll();
+ media_mgr.release (media, devindex < devices.size() ? devices[devindex] : "");
+ }
+ catch ( const Exception & e)
+ {
+ ZYPP_CAUGHT(e);
+ }
}
else if ( user == media::MediaChangeReport::RETRY ||
user == media::MediaChangeReport::CHANGE_URL )
if ( recursive )
{
ProvideDirTreeOperation op;
- provide( boost::ref(op), resource, options);
+ provide( boost::ref(op), resource, options, Pathname());
return op.result;
}
ProvideDirOperation op;
- provide( boost::ref(op), resource, options);
- return op.result;
+ provide( boost::ref(op), resource, options, Pathname());
+ return op.result;
}
media::MediaAccessId MediaSetAccess::getMediaAccessId (media::MediaNr medianr)
if (_medias.find(medianr) != _medias.end())
{
media::MediaAccessId id = _medias[medianr];
- //if (! noattach && ! media_mgr.isAttached(id))
- //media_mgr.attach(id);
return id;
}
Url url;
// code has to be adapted together with the MediaISO change.
// maybe some MediaISOURL interface should be used.
std::string isofile = url_r.getQueryParam("iso");
- str::regex e("^(.*)(cd|dvd)[0-9]+\\.iso$", str::regex::icase);
+ str::regex e("^(.*)(cd|dvd|media)[0-9]+\\.iso$", str::regex::icase);
str::smatch what;
if(str::regex_match(isofile, what, e))
else
{
std::string pathname = url_r.getPathName();
- str::regex e("^(.*)(cd|dvd)[0-9]+(/)?$", str::regex::icase);
+ str::regex e("^(.*)(cd|dvd|media)[0-9]+(/)?$", str::regex::icase);
str::smatch what;
if(str::regex_match(pathname, what, e))
{
return str;
}
-// media::MediaVerifierRef MediaSetAccess::verifier(unsigned media_nr)
-// { return media::MediaVerifierRef(new media::NoVerifier()); }
-
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////