[Bug 668297] extragear/sysadmin/libqapt/src
Jonathan Thomas
echidnaman at kubuntu.org
Sat Oct 30 03:19:28 UTC 2010
SVN commit 1191219 by jmthomas:
Use libapt-pkg's pkgCacheFile for a bunch of cache-related stuff inside QApt::Cache, rather than rolling our own. This results in the nice loss of 51 lines of code.
The class will stay due to the trustCache stuff it implements (and obviously binary/API compatibility) Whenever the need arises for a QApt2 (API break) this will likely become a thin(er) wrapper over the pkgCacheFile, with its main objective being to provide a Qt-style API. (Hopefully a trustCache solution will make it in to APT in the meanwhile, so that we and synaptic don't have to have two imlementations)
But, in the meantime, less stuff to maintain/worry about breaking. :)
CCMAIL:668297 at bugs.launchpad.net
M +10 -62 cache.cpp
--- trunk/extragear/sysadmin/libqapt/src/cache.cpp #1191218:1191219
@@ -22,11 +22,7 @@
#include <QtCore/QCoreApplication>
-#include <apt-pkg/depcache.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/pkgcachegen.h>
-#include <apt-pkg/policy.h>
+#include <apt-pkg/cachefile.h>
namespace QApt {
@@ -45,34 +41,20 @@
{
public:
CachePrivate()
- : mmap(0)
- , cache(0)
- , policy(0)
- , depCache(0)
- , list(new pkgSourceList)
+ : cache(new pkgCacheFile())
, trustCache(new QHash<pkgCache::PkgFileIterator, pkgIndexFile*>)
{
}
virtual ~CachePrivate()
{
- delete list;
delete cache;
- delete policy;
- delete depCache;
- delete mmap;
delete trustCache;
}
- CacheBuildProgress m_progressMeter;
- MMap *mmap;
+ CacheBuildProgress progressMeter;
+ pkgCacheFile *cache;
- pkgCache *cache;
- pkgPolicy *policy;
-
- pkgDepCache *depCache;
- pkgSourceList *list;
-
QHash<pkgCache::PkgFileIterator, pkgIndexFile*> *trustCache;
};
@@ -92,51 +74,17 @@
Q_D(Cache);
// delete any old structures
- if (d->cache) {
- delete d->cache;
- d->cache = 0;
- }
- if (d->policy) {
- delete d->policy;
- d->policy = 0;
- }
- if (d->depCache) {
- delete d->depCache;
- d->depCache = 0;
- }
- if (d->mmap) {
- delete d->mmap;
- d->mmap = 0;
- }
+ d->cache->Close();
- // Read the sources list
- if (!d->list->ReadMainList()) {
- return false;
- }
-
- pkgMakeStatusCache(*(d->list), d->m_progressMeter, &(d->mmap), true);
- d->m_progressMeter.Done();
- if (_error->PendingError()) {
- return false;
- }
-
// Open the cache file
- d->cache = new pkgCache(d->mmap);
- d->policy = new pkgPolicy(d->cache);
- if (!ReadPinFile(*(d->policy)) || !ReadPinDir(*(d->policy))) {
+ if (!d->cache->ReadOnlyOpen(&d->progressMeter)) {
return false;
}
- if (_error->PendingError()) {
- return false;
- }
-
- d->depCache = new pkgDepCache(d->cache, d->policy);
- d->depCache->Init(&(d->m_progressMeter));
-
d->trustCache->clear();
- if (d->depCache->DelCount() != 0 || d->depCache->InstCount() != 0) {
+ if (d->cache->GetDepCache()->DelCount() != 0 ||
+ d->cache->GetDepCache()->InstCount() != 0) {
return false;
}
@@ -147,14 +95,14 @@
{
Q_D(const Cache);
- return d->depCache;
+ return d->cache->GetDepCache();
}
pkgSourceList *Cache::list() const
{
Q_D(const Cache);
- return d->list;
+ return d->cache->GetSourceList();
}
QHash<pkgCache::PkgFileIterator, pkgIndexFile*> *Cache::trustCache() const
--
Does not work with preferences.d
https://bugs.launchpad.net/bugs/668297
You received this bug notification because you are a member of Kubuntu
Bugs, which is subscribed to qapt in ubuntu.
More information about the kubuntu-bugs
mailing list