From: Jiri Srain Date: Thu, 6 Apr 2006 14:56:30 +0000 (+0000) Subject: fixed setting autorefresh flag for installation sources X-Git-Tag: BASE-SuSE-SLE-10-SP2-Branch~1153 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c3f335c47d0714008eefd4af1e9811fa6e48448;p=platform%2Fupstream%2Flibzypp.git fixed setting autorefresh flag for installation sources --- diff --git a/package/libzypp.changes b/package/libzypp.changes index a96d733..dac53e3 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Thu Apr 6 16:37:49 CEST 2006 - jsrain@suse.de + +- fixed setting autorefresh flag for installation sources + +------------------------------------------------------------------- Thu Apr 6 15:53:02 CEST 2006 - kkaempf@suse.de - drop patches with incompatible architecture. diff --git a/zypp/media/MediaAccess.cc b/zypp/media/MediaAccess.cc index dc3d1ca..7a033e2 100644 --- a/zypp/media/MediaAccess.cc +++ b/zypp/media/MediaAccess.cc @@ -150,6 +150,14 @@ MediaAccess::downloads(const Url &url) return (scheme == "ftp" || scheme == "http" || scheme == "https"); } +// STATIC +bool +MediaAccess::canBeVolatile(const Url &url) +{ + std::string scheme( url.getScheme()); + return ! (scheme == "cd" || scheme == "dvd"); +} + // Type of media if open, otherwise NONE. std::string MediaAccess::protocol() const diff --git a/zypp/media/MediaAccess.h b/zypp/media/MediaAccess.h index 2ddd059..ec4f8d1 100644 --- a/zypp/media/MediaAccess.h +++ b/zypp/media/MediaAccess.h @@ -119,6 +119,17 @@ namespace zypp { */ static bool downloads(const Url &url); + /** + * Hint whether the media can provide volatile contents + * + * @note This hint is based on the \p url scheme + * only and does not imply, that the URL is valid. + * + * @param url The media URL to check. + * @return True, if the files are downloaded. + */ + static + bool canBeVolatile(const Url &url); /** * Used Protocol if media is opened, otherwise 'unknown'. diff --git a/zypp/source/SourceImpl.cc b/zypp/source/SourceImpl.cc index 4da11fa..5048c68 100644 --- a/zypp/source/SourceImpl.cc +++ b/zypp/source/SourceImpl.cc @@ -65,8 +65,8 @@ namespace zypp _cache_dir = cache_dir_r; _subscribed = true; - // for remote sources we enable autorefresh by default - _autorefresh = media::MediaAccess::downloads( _url ); + // for sources which are neither CD nor DVD we enable autorefresh by default + _autorefresh = media::MediaAccess::canBeVolatile( _url ); try { diff --git a/zypp/source/susetags/ProductMetadataParser.cc b/zypp/source/susetags/ProductMetadataParser.cc index 36d4a2c..5d33b65 100644 --- a/zypp/source/susetags/ProductMetadataParser.cc +++ b/zypp/source/susetags/ProductMetadataParser.cc @@ -64,6 +64,7 @@ namespace zypp } std::string buffer; + volatile_content = false; while(file && !file.eof()) { getline(file, buffer); @@ -148,6 +149,8 @@ namespace zypp parseFileCheckSum( key, value, prodImpl->_descr_files_checksums); else if(key == "KEY") parseFileCheckSum( key, value, prodImpl->_signing_keys); + else if(key == "VOLATILE_CONTENT") + volatile_content = true; else DBG << "Unknown key [" << key << "] with value [" << value << "]" << std::endl; } diff --git a/zypp/source/susetags/ProductMetadataParser.h b/zypp/source/susetags/ProductMetadataParser.h index ea53a56..7d8510a 100644 --- a/zypp/source/susetags/ProductMetadataParser.h +++ b/zypp/source/susetags/ProductMetadataParser.h @@ -74,6 +74,9 @@ namespace zypp */ void parseFileCheckSum( const std::string &key, const std::string &value, std::map &container); + + bool volatile_content; + }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/source/susetags/SuseTagsImpl.cc b/zypp/source/susetags/SuseTagsImpl.cc index 3464804..f5aa072 100644 --- a/zypp/source/susetags/SuseTagsImpl.cc +++ b/zypp/source/susetags/SuseTagsImpl.cc @@ -428,6 +428,7 @@ namespace zypp MIL << "Product: " << product->summary() << endl; store.insert( product ); _prodImpl = p.prodImpl; + _autorefresh = p.volatile_content && media::MediaAccess::canBeVolatile( _url ); } catch (Exception & excpt_r) { ERR << "cannot parse content file" << endl;