///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
- for_( it, pool.byKindBegin<Product>(), pool.byKindEnd<Product>() )
+ SEC << zypp::getZYpp()->diskUsage() << endl;
+
+ for_( it, pool.begin(), pool.end() )
{
- Product::constPtr p( asKind<Product>( *it ) );
- USR << p << endl;
- MIL << p->type() << endl;
- MIL << p->releaseNotesUrl() << endl;
- MIL << p->updateUrls() << endl;
- MIL << p->extraUrls() << endl;
- MIL << p->optionalUrls() << endl;
- MIL << p->flags() << endl;
- MIL << p->shortName() << endl;
- MIL << p->distributionName() << endl;
- MIL << p->distributionEdition() << endl;
+ //MIL << *it << endl;
+ //DBG << (*it)->diskusage() << endl;
}
+ PoolItem pu ( getPi<Package>("amarok") );
+ PoolItem pi ( getPi<Package>("amarok",Edition("1.4.7-37")) );
+
+ pi.status().setTransact( true, ResStatus::USER );
+ SEC << zypp::getZYpp()->diskUsage() << endl;
+
+ pu.status().setTransact( true, ResStatus::USER );
+ SEC << zypp::getZYpp()->diskUsage() << endl;
+
///////////////////////////////////////////////////////////////////
INT << "===[END]============================================" << endl << endl;
zypp::base::LogControl::instance().logNothing();
return 0;
- SEC << zypp::getZYpp()->diskUsage() << endl;
-
if ( 0 )
{
PoolItem pi ( getPi<Package>("amarok") );
#include <fstream>
#include "zypp/base/Easy.h"
-#include "zypp/base/Logger.h"
+#include "zypp/base/LogTools.h"
#include "zypp/base/String.h"
#include "zypp/DiskUsageCounter.h"
-#include "zypp/Package.h"
+#include "zypp/sat/Pool.h"
+#include "zypp/sat/detail/PoolImpl.h"
using std::endl;
namespace zypp
{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace
- { /////////////////////////////////////////////////////////////////
-
- inline void addDu( DiskUsageCounter::MountPointSet & result_r, DiskUsage & du_r )
- {
- // traverse mountpoints in reverse order. This is done beacuse
- // DiskUsage::extract computes the mountpoint size, and then
- // removes the entry. So we must process leaves first.
- for_( mpit, result_r.rbegin(), result_r.rend() )
- {
- // Extract usage for the mount point
- DiskUsage::Entry entry = du_r.extract( mpit->dir );
- // Adjust the data.
- mpit->pkg_size += entry._size;
- }
- }
-
- inline void delDu( DiskUsageCounter::MountPointSet & result_r, DiskUsage & du_r )
- {
- // traverse mountpoints in reverse order. This is done beacuse
- // DiskUsage::extract computes the mountpoint size, and then
- // removes the entry. So we must process leaves first.
- for_( mpit, result_r.rbegin(), result_r.rend() )
- {
- // Extract usage for the mount point
- DiskUsage::Entry entry = du_r.extract( mpit->dir );
- // Adjust the data.
- mpit->pkg_size -= entry._size;
- }
- }
-
- /////////////////////////////////////////////////////////////////
- } // namespace
- ///////////////////////////////////////////////////////////////////
-
- DiskUsageCounter::MountPointSet DiskUsageCounter::disk_usage( const ResPool & pool_r )
+ DiskUsageCounter::MountPointSet DiskUsageCounter::disk_usage( const ResPool & pool_r )
{
DiskUsageCounter::MountPointSet result = mps;
return result;
}
- // set used size after commit to the current used size
- for_( it, result.begin(), result.end() )
+ sat::Pool satpool( sat::Pool::instance() );
+
+ // init satsolver result vector with mountpoints
+ static const ::DUChanges _initdu = { 0, 0, 0 };
+ std::vector< ::DUChanges> duchanges( result.size(), _initdu );
{
- it->pkg_size = it->used_size;
+ unsigned idx = 0;
+ for_( it, result.begin(), result.end() )
+ {
+ duchanges[idx].path = it->dir.c_str();
+ ++idx;
+ }
}
- // iterate through all items
+ // build installedmap (installed != transact)
+ // stays installed or gets installed
+ ::Map installedmap;
+ ::map_init( &installedmap, satpool.capacity() );
for_( it, pool_r.begin(), pool_r.end() )
{
- // skip items that do not transact
- if ( ! it->status().transacts() )
- continue;
-
- DiskUsage du( (*it)->diskusage() );
-
- // skip items without du info
- if ( du.empty() )
- continue; // or find some substitute info
-
- // Adjust the data.
- if ( it->status().isUninstalled() )
+ if ( it->status().isInstalled() != it->status().transacts() )
{
- // an uninstalled item gets installed:
- addDu( result, du );
-
- // While there is no valid solver result, items to update
- // are selected, but installed old versions are not yet
- // deselected. We try to compensate this:
- if ( ! (*it)->installOnly() )
- {
- // Item to update -> check the installed ones.
- for_( nit, pool_r.byIdentBegin( *it ), pool_r.byIdentEnd( *it ) )
- { // same kind and name
- if ( nit->status().staysInstalled() ) // and unselected installed
- {
- DiskUsage ndu( (*nit)->diskusage() );
- if ( ! ndu.empty() )
- {
- delDu( result, ndu );
- }
- }
- }
- }
+ MAPSET( &installedmap, it->satSolvable().id() );
}
- else
+ }
+
+ // now calc...
+ ::pool_calc_duchanges( satpool.get(),
+ satpool.systemRepo().get(),
+ &installedmap,
+ &duchanges[0],
+ duchanges.size() );
+
+ // and process the result
+ {
+ unsigned idx = 0;
+ for_( it, result.begin(), result.end() )
{
- // an installed item gets deleted:
- delDu( result, du );
+ static const ByteCount blockAdjust( 2, ByteCount::K ); // (files * blocksize) / (2 * 1K)
+
+ it->pkg_size = it->used_size // current usage
+ + duchanges[idx].kbytes // package data size
+ + ( duchanges[idx].files * it->block_size / blockAdjust ); // half block per file
+ ++idx;
}
}
+
return result;
}
<< " ts: " << obj.total_size
<< " us: " << obj.used_size
<< " (+-: " << (obj.pkg_size-obj.used_size)
- << ")]" << std::endl;
+ << ")]";
return str;
}