From 90c24750702f847b1f883091028eac66244f80cd Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Wed, 21 May 2008 17:01:59 +0000 Subject: [PATCH] - add OnmediaLocation::optional as a hint to the downloader --- zypp/OnMediaLocation.h | 74 +++++++++++++++++++++++++++++++++++++++++---- zypp/repo/yum/Downloader.cc | 5 +-- 2 files changed, 71 insertions(+), 8 deletions(-) diff --git a/zypp/OnMediaLocation.h b/zypp/OnMediaLocation.h index 84b6144..e947990 100644 --- a/zypp/OnMediaLocation.h +++ b/zypp/OnMediaLocation.h @@ -44,6 +44,7 @@ namespace zypp /** Default ctor indicating no media access. */ OnMediaLocation() : _medianr( 0 ) + , _optional(false) {} /** Ctor taking a filename and media number (defaults to 1). */ @@ -53,12 +54,49 @@ namespace zypp {} public: + /** + * media number where the resource is located. + * for a url cd:// this could be 1..N. + * for a url of type http://host/path/CD1, a media number 2 + * means looking on http://host/path/CD1/../CD2 + */ unsigned medianr() const { return _medianr; } + /** + * The path to the resource relatve to the url and path. + * If the base is http://novell.com/download/repository, the + * resource filename could be "/repodata/repomd.xml" + */ const Pathname & filename() const { return _filename; } + /** + * the checksum of the resource + */ const CheckSum & checksum() const { return _checksum; } + /** + * The size of the resource on the server. Therefore + * the size of the download. + */ const ByteCount & downloadSize() const { return _downloadsize; } + /** + * The size of the resource once it has been uncompressed + * or unpacked. + * If the file is file.txt.gz then this is the size of + * file.txt + */ const ByteCount & openSize() const { return _opendownloadsize; } + /** + * The checksum of the resource once it has been uncompressed + * or unpacked. + * If the file is file.txt.gz then this is the checksum of + * file.txt + */ const CheckSum & openChecksum() const { return _openchecksum; } + /** + * whether this is an optional resource. That is a file that + * may not be present. This is just a hint to the resource + * downloader to not error in case the not found resource is + * not found. + */ + const bool optional() const { return _optional; } public: /** Unset \c filename and set \c medianr to \c 0. */ @@ -86,19 +124,42 @@ namespace zypp OnMediaLocation & setOpenChecksum( const CheckSum & val_r ) { _openchecksum = val_r; return *this; } + /** + * Set the wether the resource is optional or not + * \see optional + */ + OnMediaLocation & setOptional( bool val ) + { _optional = val; return *this; } + public: - /** Individual manipulation of \c medianr. - * Using \ref setLocation is prefered. + /** + * Individual manipulation of \c medianr. + * Using \ref setLocation is prefered. */ - OnMediaLocation & changeMedianr( unsigned val_r ) + OnMediaLocation & setMedianr( unsigned val_r ) { _medianr = val_r; return *this; } - /** Individual manipulation of \c filename. + /** + * Individual manipulation of \c medianr. + * Use \ref setMediaNr instead + */ + ZYPP_DEPRECATED OnMediaLocation & changeMedianr( unsigned val_r ) + { return setMedianr(val_r); } + + /** + * Individual manipulation of \c filename. * Using \ref setLocation is prefered. - */ - OnMediaLocation & changeFilename( const Pathname & val_r ) + */ + OnMediaLocation &setFilename( const Pathname & val_r ) { _filename = val_r; return *this; } + /** + * Individual manipulation of \c filename. + * Use \ref setFilename instead. + */ + ZYPP_DEPRECATED OnMediaLocation & changeFilename( const Pathname & val_r ) + { return setFilename(val_r); } + private: unsigned _medianr; Pathname _filename; @@ -106,6 +167,7 @@ namespace zypp ByteCount _downloadsize; ByteCount _opendownloadsize; CheckSum _openchecksum; + bool _optional; }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/repo/yum/Downloader.cc b/zypp/repo/yum/Downloader.cc index 903d0b9..add26b8 100644 --- a/zypp/repo/yum/Downloader.cc +++ b/zypp/repo/yum/Downloader.cc @@ -109,15 +109,16 @@ void Downloader::download( MediaSetAccess &media, if ( _media_ptr->doesFileExist(sigpath) ) { - this->enqueue( OnMediaLocation(sigpath,1) ); + this->enqueue( OnMediaLocation(sigpath,1).setOptional(true) ); this->start( dest_dir, *_media_ptr); this->reset(); sigchecker = SignatureFileChecker(dest_dir + sigpath); } + if ( _media_ptr->doesFileExist(keypath) ) { - this->enqueue( OnMediaLocation(keypath,1) ); + this->enqueue( OnMediaLocation(keypath,1).setOptional(true) ); this->start( dest_dir, *_media_ptr); this->reset(); sigchecker.addPublicKey(dest_dir + keypath); -- 2.7.4