From: Duncan Mac-Vicar P Date: Mon, 27 Aug 2007 21:51:29 +0000 (+0000) Subject: - following behaviour for setPartitions X-Git-Tag: BASE-SuSE-Linux-10_3-Branch~191 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd62c0c7a9302749d76dcac818b3318441eb79f8;p=platform%2Fupstream%2Flibzypp.git - following behaviour for setPartitions - if they are not set, they are detected - if they are set, that value is used. - if value set or detected is empty, all disk usage information is read. Otherwise just values in those mount points. Should work for installation as long as detectPartitions is empty at installation. (#293039) --- diff --git a/tests/cache/CacheStore_test.cc b/tests/cache/CacheStore_test.cc index cb090a8..d91046e 100644 --- a/tests/cache/CacheStore_test.cc +++ b/tests/cache/CacheStore_test.cc @@ -71,7 +71,13 @@ void check_kdelibs3_package( Package::Ptr p ) BOOST_CHECK_EQUAL( p->size(), 38850584); BOOST_CHECK_EQUAL( p->location().downloadSize(), 16356019); - BOOST_CHECK_EQUAL( p->diskusage().size(), (unsigned)3); + BOOST_CHECK_EQUAL( p->diskusage().size(), (unsigned) 181); + for ( DiskUsage::iterator it = p->diskusage().begin(); + it != p->diskusage().end(); + ++it ) + { + MIL << "disk usage entry " << (*it).path << endl; + } } /** @@ -419,11 +425,12 @@ init_unit_test_suite( int argc, char *argv[] ) (std::string const*)params, params+1)); DiskUsageCounter::MountPointSet mounts; - mounts.insert( DiskUsageCounter::MountPoint("/") ); - mounts.insert( DiskUsageCounter::MountPoint("/etc") ); - mounts.insert( DiskUsageCounter::MountPoint("/opt/kde3/share/mimelnk/video") ); - mounts.insert( DiskUsageCounter::MountPoint("/foo") ); - mounts.insert( DiskUsageCounter::MountPoint("/bar") ); +// mounts.insert( DiskUsageCounter::MountPoint("/") ); +// mounts.insert( DiskUsageCounter::MountPoint("/etc") ); +// mounts.insert( DiskUsageCounter::MountPoint("/opt/kde3/share/mimelnk/video") ); +// mounts.insert( DiskUsageCounter::MountPoint("/foo") ); +// mounts.insert( DiskUsageCounter::MountPoint("/bar") ); + getZYpp()->setPartitions(mounts); test->add(BOOST_PARAM_TEST_CASE(&cache_write_susetags_normal_test, diff --git a/zypp/parser/susetags/PackagesDuFileReader.cc b/zypp/parser/susetags/PackagesDuFileReader.cc index e74ff4e..bf6ca76 100644 --- a/zypp/parser/susetags/PackagesDuFileReader.cc +++ b/zypp/parser/susetags/PackagesDuFileReader.cc @@ -47,10 +47,6 @@ namespace zypp { _mounts = getZYpp()->getPartitions(); - // try to detect partitions if empty - if (_mounts.empty() ) - _mounts = DiskUsageCounter::detectMountPoints(); - for ( DiskUsageCounter::MountPointSet::const_iterator it = _mounts.begin(); it != _mounts.end(); ++ it ) diff --git a/zypp/zypp_detail/ZYppImpl.cc b/zypp/zypp_detail/ZYppImpl.cc index 30f491b..3c5b423 100644 --- a/zypp/zypp_detail/ZYppImpl.cc +++ b/zypp/zypp_detail/ZYppImpl.cc @@ -133,7 +133,6 @@ namespace zypp , _target(0) , _resolver( new Resolver(_pool.accessor()) ) , _architecture( defaultArchitecture() ) - , _disk_usage() { MIL << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl; MIL << "defaultTextLocale: '" << _textLocale << "'" << endl; @@ -180,13 +179,21 @@ namespace zypp } DiskUsageCounter::MountPointSet ZYppImpl::diskUsage() - { return _disk_usage.disk_usage(pool()); } + { return _disk_usage->disk_usage(pool()); } void ZYppImpl::setPartitions(const DiskUsageCounter::MountPointSet &mp) - { _disk_usage.setMountPoints(mp); } + { + _disk_usage.reset(new DiskUsageCounter()); + _disk_usage->setMountPoints(mp); + } DiskUsageCounter::MountPointSet ZYppImpl::getPartitions() const - { return _disk_usage.getMountPoints(); } + { + if (_disk_usage) + return _disk_usage->getMountPoints(); + else + return DiskUsageCounter::detectMountPoints(); + } //------------------------------------------------------------------------ // target diff --git a/zypp/zypp_detail/ZYppImpl.h b/zypp/zypp_detail/ZYppImpl.h index e8fdbd4..5cec314 100644 --- a/zypp/zypp_detail/ZYppImpl.h +++ b/zypp/zypp_detail/ZYppImpl.h @@ -164,7 +164,7 @@ namespace zypp /** */ Pathname _home_path; /** defined mount points, used for disk usage counting */ - DiskUsageCounter _disk_usage; + shared_ptr _disk_usage; }; ///////////////////////////////////////////////////////////////////