summaryrefslogtreecommitdiff
path: root/apt-pkg/depcache.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2010-06-03 09:50:06 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2010-06-03 09:50:06 +0200
commit81305a0b30cc12aa6d32081bbdcf930907ecfbbe (patch)
tree14369bed1e8bd905c7ee886d9316f5cfb06eeaeb /apt-pkg/depcache.cc
parente2c66de5c5e63d8400efb0522c31fbe1ec225f93 (diff)
downloadapt-81305a0b30cc12aa6d32081bbdcf930907ecfbbe.tar.gz
deprecate AddSize with Multiplier as it is unused and switch to
boolean instead to handle the sizes more gracefully.
Diffstat (limited to 'apt-pkg/depcache.cc')
-rw-r--r--apt-pkg/depcache.cc73
1 files changed, 71 insertions, 2 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 6e0eeab5b..786b20ec0 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -407,8 +407,11 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
/*}}}*/
// DepCache::AddSizes - Add the packages sizes to the counters /*{{{*/
// ---------------------------------------------------------------------
-/* Call with Mult = -1 to preform the inverse opration */
-void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult)
+/* Call with Mult = -1 to preform the inverse opration
+ The Mult increases the complexity of the calulations here and is unused -
+ or do we really have a usecase for removing the size of a package two
+ times? So let us replace it with a simple bool and be done with it… */
+__deprecated void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult)
{
StateCache &P = PkgState[Pkg->ID];
@@ -454,6 +457,72 @@ void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult)
}
}
/*}}}*/
+// DepCache::AddSizes - Add the packages sizes to the counters /*{{{*/
+// ---------------------------------------------------------------------
+/* Call with Inverse = true to preform the inverse opration */
+void pkgDepCache::AddSizes(const PkgIterator &Pkg, bool const &Inverse)
+{
+ StateCache &P = PkgState[Pkg->ID];
+
+ if (Pkg->VersionList == 0)
+ return;
+
+ if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure &&
+ P.Keep() == true)
+ return;
+
+ // Compute the size data
+ if (P.NewInstall() == true)
+ {
+ if (Inverse == false) {
+ iUsrSize += P.InstVerIter(*this)->InstalledSize;
+ iDownloadSize += P.InstVerIter(*this)->Size;
+ } else {
+ iUsrSize -= P.InstVerIter(*this)->InstalledSize;
+ iDownloadSize -= P.InstVerIter(*this)->Size;
+ }
+ return;
+ }
+
+ // Upgrading
+ if (Pkg->CurrentVer != 0 &&
+ (P.InstallVer != (Version *)Pkg.CurrentVer() ||
+ (P.iFlags & ReInstall) == ReInstall) && P.InstallVer != 0)
+ {
+ if (Inverse == false) {
+ iUsrSize -= Pkg.CurrentVer()->InstalledSize;
+ iUsrSize += P.InstVerIter(*this)->InstalledSize;
+ iDownloadSize += P.InstVerIter(*this)->Size;
+ } else {
+ iUsrSize -= P.InstVerIter(*this)->InstalledSize;
+ iUsrSize += Pkg.CurrentVer()->InstalledSize;
+ iDownloadSize -= P.InstVerIter(*this)->Size;
+ }
+ return;
+ }
+
+ // Reinstall
+ if (Pkg.State() == pkgCache::PkgIterator::NeedsUnpack &&
+ P.Delete() == false)
+ {
+ if (Inverse == false)
+ iDownloadSize += P.InstVerIter(*this)->Size;
+ else
+ iDownloadSize -= P.InstVerIter(*this)->Size;
+ return;
+ }
+
+ // Removing
+ if (Pkg->CurrentVer != 0 && P.InstallVer == 0)
+ {
+ if (Inverse == false)
+ iUsrSize -= Pkg.CurrentVer()->InstalledSize;
+ else
+ iUsrSize += Pkg.CurrentVer()->InstalledSize;
+ return;
+ }
+}
+ /*}}}*/
// DepCache::AddStates - Add the package to the state counter /*{{{*/
// ---------------------------------------------------------------------
/* This routine is tricky to use, you must make sure that it is never