From: Duncan Mac-Vicar P Date: Wed, 21 May 2008 17:02:02 +0000 (+0000) Subject: - dont check for existence of keys but provde a way to retrieve optional X-Git-Tag: 6.6.0~853 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1e185f62b5f412076de29f4a1250fbcc806fe4fd;p=platform%2Fupstream%2Flibzypp.git - dont check for existence of keys but provde a way to retrieve optional files, in order to avoid a HEAD request. related to bnc#381280 --- diff --git a/zypp/Fetcher.cc b/zypp/Fetcher.cc index 5267b3ce3..0ce398266 100644 --- a/zypp/Fetcher.cc +++ b/zypp/Fetcher.cc @@ -213,6 +213,14 @@ namespace zypp catch (Exception & excpt_r) { ZYPP_CAUGHT(excpt_r); + + // do not error on optional files + if ((*it_res)->location.optional() ) + { + MIL << "Skipping optional file " << (*it_res)->location << endl; + continue; + } + excpt_r.remember("Can't provide " + (*it_res)->location.filename().asString() + " : " + excpt_r.msg()); ZYPP_RETHROW(excpt_r); } diff --git a/zypp/MediaSetAccess.cc b/zypp/MediaSetAccess.cc index 3cd0745fd..f28b3d1dd 100644 --- a/zypp/MediaSetAccess.cc +++ b/zypp/MediaSetAccess.cc @@ -69,16 +69,6 @@ IMPL_PTR_TYPE(MediaSetAccess); } } -// callback::SendReport 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 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() ); @@ -101,13 +91,23 @@ IMPL_PTR_TYPE(MediaSetAccess); Pathname MediaSetAccess::provideFile( const OnMediaLocation & on_media_file ) { - return provideFile( on_media_file.filename(), on_media_file.medianr() ); + // if the file is optional we don't want a retry, ignore, abort + // callback, but just abort inmediately if it does not exist + // therefore we pass checkonly true + if (on_media_file.optional() ) + return provideFileInternal( on_media_file.filename(), + on_media_file.medianr(), + true, true); + + return provideFileInternal( on_media_file.filename(), + on_media_file.medianr(), + true, false ); } Pathname MediaSetAccess::provideFile(const Pathname & file, unsigned media_nr ) { - return provideFileInternal( file, media_nr, false, false); + return provideFileInternal( file, media_nr, false, false ); } bool MediaSetAccess::doesFileExist(const Pathname & file, unsigned media_nr ) diff --git a/zypp/MediaSetAccess.h b/zypp/MediaSetAccess.h index 09ec05dbd..00847ec51 100644 --- a/zypp/MediaSetAccess.h +++ b/zypp/MediaSetAccess.h @@ -113,6 +113,11 @@ namespace zypp * \param on_media_file location of the file on media * \return local pathname of the requested file * + * If \p on_media_file is marked as optional, then + * in case of failure the user interaction callbacks + * will be ignored and the exception will throw + * inmediately. + * * \throws MediaException if a problem occurs, * see \ref media::MediaManager::provideFile() */ diff --git a/zypp/repo/susetags/Downloader.cc b/zypp/repo/susetags/Downloader.cc index 6b5ccb816..b29ae419c 100644 --- a/zypp/repo/susetags/Downloader.cc +++ b/zypp/repo/susetags/Downloader.cc @@ -49,24 +49,22 @@ void Downloader::download( MediaSetAccess &media, SignatureFileChecker sigchecker; Pathname sig = _path + "/content.asc"; - if ( media.doesFileExist(sig) ) - { - this->enqueue( OnMediaLocation( sig, 1 ) ); - this->start( dest_dir, media ); - this->reset(); - sigchecker = SignatureFileChecker( dest_dir + sig ); - } + this->enqueue( OnMediaLocation( sig, 1 ).setOptional(true) ); + this->start( dest_dir, media ); + this->reset(); + + if ( PathInfo(dest_dir + sig).isExist() ) + sigchecker = SignatureFileChecker( dest_dir + sig ); Pathname key = _path + "/content.key"; - if ( media.doesFileExist(key) ) - { - this->enqueue( OnMediaLocation( key, 1 ) ); - this->start( dest_dir, media ); - this->reset(); - sigchecker.addPublicKey(dest_dir + key); - } + // the key may not exist + this->enqueue( OnMediaLocation( key, 1 ).setOptional(true) ); + this->start( dest_dir, media ); + this->reset(); + if ( PathInfo(dest_dir + key).isExist() ) + sigchecker.addPublicKey(dest_dir + key); this->enqueue( OnMediaLocation( _path + "/content", 1 ), sigchecker ); this->start( dest_dir, media ); diff --git a/zypp/repo/yum/Downloader.cc b/zypp/repo/yum/Downloader.cc index add26b80c..9af9e5977 100644 --- a/zypp/repo/yum/Downloader.cc +++ b/zypp/repo/yum/Downloader.cc @@ -107,24 +107,23 @@ void Downloader::download( MediaSetAccess &media, SignatureFileChecker sigchecker; - if ( _media_ptr->doesFileExist(sigpath) ) - { - this->enqueue( OnMediaLocation(sigpath,1).setOptional(true) ); - this->start( dest_dir, *_media_ptr); - this->reset(); - sigchecker = SignatureFileChecker(dest_dir + sigpath); - } - + // this file is optional, may be the signature is not there + this->enqueue( OnMediaLocation(sigpath,1).setOptional(true) ); + this->start( dest_dir, *_media_ptr); + this->reset(); - if ( _media_ptr->doesFileExist(keypath) ) - { - this->enqueue( OnMediaLocation(keypath,1).setOptional(true) ); - this->start( dest_dir, *_media_ptr); - this->reset(); - sigchecker.addPublicKey(dest_dir + keypath); - } + // only need a checker if the signature exist. + if ( PathInfo(dest_dir + sigpath).isExist() ) + sigchecker = SignatureFileChecker(dest_dir + sigpath); + + // the key path may also not be there + this->enqueue( OnMediaLocation(keypath,1).setOptional(true) ); + this->start( dest_dir, *_media_ptr); + this->reset(); + + if ( PathInfo(dest_dir + keypath).isExist() ) + sigchecker.addPublicKey(dest_dir + keypath); - this->start( dest_dir, *_media_ptr ); if ( ! progress.tick() )