- Reenable diskusage calculation (bnc #395051)
authorMichael Andres <ma@suse.de>
Wed, 28 May 2008 16:56:42 +0000 (16:56 +0000)
committerMichael Andres <ma@suse.de>
Wed, 28 May 2008 16:56:42 +0000 (16:56 +0000)
VERSION.cmake
devel/devel.ma/NewPool.cc
package/libzypp.changes
zypp/DiskUsageCounter.cc
zypp/DiskUsageCounter.h

index df1f9f8..4f7ff3c 100644 (file)
@@ -47,4 +47,4 @@
 SET(LIBZYPP_MAJOR "4")
 SET(LIBZYPP_MINOR "25")
 SET(LIBZYPP_COMPATMINOR "24")
-SET(LIBZYPP_PATCH "0")
+SET(LIBZYPP_PATCH "1")
index a7cf65b..6e69a75 100644 (file)
@@ -559,29 +559,29 @@ try {
   ///////////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////////
 
-  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") );
index f0439b1..ad053db 100644 (file)
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Wed May 28 18:54:27 CEST 2008 - ma@suse.de
+
+- Reenable diskusage calculation (bnc #395051)
+- version 4.25.1
+- revision 10273
+
+-------------------------------------------------------------------
 Wed May 28 18:50:11 CEST 2008 - jkupec@suse.cz
 
 - RepoManager::packagesPath(RepoInfo) added (bnc #394728)
index 8dc06d0..88ffa1b 100644 (file)
@@ -18,11 +18,12 @@ extern "C"
 #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;
 
@@ -30,43 +31,7 @@ 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;
 
@@ -76,56 +41,53 @@ namespace zypp
       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;
   }
 
@@ -274,7 +236,7 @@ namespace zypp
         << " ts: " << obj.total_size
         << " us: " << obj.used_size
         << " (+-: " << (obj.pkg_size-obj.used_size)
-        << ")]" << std::endl;
+        << ")]";
     return str;
   }
 
index 4b6b714..64ccc4d 100644 (file)
@@ -40,15 +40,15 @@ namespace zypp
       /**
        * Block size of the mount point
        **/
-      long long block_size;       
+      long long block_size;
 
       /**
-       * Total size in kB (1024)
+       * Total size in K (1024)
        **/
       long long total_size;
 
       /**
-       * Used size in kB (1024)
+       * Used size in  (1024)
        **/
       long long used_size;
 
@@ -99,10 +99,10 @@ namespace zypp
     MountPointSet mps;
   };
   ///////////////////////////////////////////////////////////////////
-  
+
   /** \relates DiskUsageCounter::MountPoint Stream output */
   std::ostream & operator<<( std::ostream & str, const DiskUsageCounter::MountPoint & obj );
-  
+
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////