From cad2907f42ce4cb439fb7da2e901604491f1083f Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Fri, 2 May 2008 07:32:24 +0000 Subject: [PATCH] cache decision for repository depend on his url. http,ftp and smb cache packages. --- tests/zypp/RepoManager_test.cc | 15 +++++++++++++++ zypp/RepoInfo.cc | 9 +++++++++ zypp/RepoInfo.h | 2 ++ 3 files changed, 26 insertions(+) diff --git a/tests/zypp/RepoManager_test.cc b/tests/zypp/RepoManager_test.cc index 366ab8e..f4d4071 100644 --- a/tests/zypp/RepoManager_test.cc +++ b/tests/zypp/RepoManager_test.cc @@ -137,3 +137,18 @@ BOOST_AUTO_TEST_CASE(repomanager_test) manager.buildCache(repo); } +BOOST_AUTO_TEST_CASE(repo_seting_test) +{ + RepoInfo repo; + repo.setAlias("foo"); + repo.addBaseUrl(string("http://test.org")); + BOOST_CHECK_MESSAGE( repo.keepPackages(), "http scheme is not cached"); + repo.setBaseUrl(string("ftp://test.org")); + BOOST_CHECK_MESSAGE( repo.keepPackages(), "ftp scheme is not cached"); + repo.setBaseUrl(string("smb://test.org")); + BOOST_CHECK_MESSAGE( repo.keepPackages(), "smb scheme is not cached"); + repo.setBaseUrl(string("file:///test.txt")); + BOOST_CHECK_MESSAGE( !repo.keepPackages(), "file scheme is cached"); + repo.setBaseUrl(string("http://test.org")); + BOOST_CHECK_MESSAGE( repo.keepPackages(), "cache is depend on second url."); +} diff --git a/zypp/RepoInfo.cc b/zypp/RepoInfo.cc index a4a0a8e..6599c11 100644 --- a/zypp/RepoInfo.cc +++ b/zypp/RepoInfo.cc @@ -146,6 +146,15 @@ namespace zypp RepoInfo & RepoInfo::addBaseUrl( const Url &url ) { + if ( _pimpl->baseUrls.size()==0 ) //first url + { + string scheme = url.getScheme(); + if ( scheme == "http" || scheme == "ftp" || scheme == "smb" ) + setKeepPackages(true); + else + setKeepPackages(false); + } + _pimpl->baseUrls.insert(url); return *this; } diff --git a/zypp/RepoInfo.h b/zypp/RepoInfo.h index 58b1a0c..0903701 100644 --- a/zypp/RepoInfo.h +++ b/zypp/RepoInfo.h @@ -242,6 +242,7 @@ namespace zypp /** * Add a base url. \see baseUrls * \param url The base url for the repository. + * \note can change keepPackages,so change it after this call * * To recreate the base URLs list, use \ref setBaseUrl(const Url &) followed * by addBaseUrl(). @@ -250,6 +251,7 @@ namespace zypp /** * Clears current base URL list and adds \a url. + * \note can change keepPackages,so change it after this call */ RepoInfo & setBaseUrl( const Url &url ); -- 2.7.4