summaryrefslogtreecommitdiff
path: root/apt-pkg/depcache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/depcache.cc')
-rw-r--r--apt-pkg/depcache.cc87
1 files changed, 78 insertions, 9 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 6c73b9cfd..3ae5f5953 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];
@@ -422,8 +425,8 @@ void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult)
// Compute the size data
if (P.NewInstall() == true)
{
- iUsrSize += (signed)(Mult*P.InstVerIter(*this)->InstalledSize);
- iDownloadSize += (signed)(Mult*P.InstVerIter(*this)->Size);
+ iUsrSize += (signed long long)(Mult*P.InstVerIter(*this)->InstalledSize);
+ iDownloadSize += (signed long long)(Mult*P.InstVerIter(*this)->Size);
return;
}
@@ -432,9 +435,9 @@ void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult)
(P.InstallVer != (Version *)Pkg.CurrentVer() ||
(P.iFlags & ReInstall) == ReInstall) && P.InstallVer != 0)
{
- iUsrSize += (signed)(Mult*((signed)P.InstVerIter(*this)->InstalledSize -
- (signed)Pkg.CurrentVer()->InstalledSize));
- iDownloadSize += (signed)(Mult*P.InstVerIter(*this)->Size);
+ iUsrSize += (signed long long)(Mult*((signed long long)P.InstVerIter(*this)->InstalledSize -
+ (signed long long)Pkg.CurrentVer()->InstalledSize));
+ iDownloadSize += (signed long long)(Mult*P.InstVerIter(*this)->Size);
return;
}
@@ -442,14 +445,80 @@ void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult)
if (Pkg.State() == pkgCache::PkgIterator::NeedsUnpack &&
P.Delete() == false)
{
- iDownloadSize += (signed)(Mult*P.InstVerIter(*this)->Size);
+ iDownloadSize += (signed long long)(Mult*P.InstVerIter(*this)->Size);
return;
}
// Removing
if (Pkg->CurrentVer != 0 && P.InstallVer == 0)
{
- iUsrSize -= (signed)(Mult*Pkg.CurrentVer()->InstalledSize);
+ iUsrSize -= (signed long long)(Mult*Pkg.CurrentVer()->InstalledSize);
+ return;
+ }
+}
+ /*}}}*/
+// 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;
}
}