[Bug 839411] [libqapt/1.2] src: If the xapian index is not found in openXapianIndex, make xapianIndexNeedsUpdate()

Jonathan Thomas echidnaman at kubuntu.org
Fri Sep 2 21:29:43 UTC 2011


Git commit e4090ffc906e3543c4e64e2afee64a02e71a53b1 by Jonathan Thomas.
Committed on 02/09/2011 at 23:09.
Pushed by jmthomas into branch '1.2'.

If the xapian index is not found in openXapianIndex, make xapianIndexNeedsUpdate()
return true.

Fixes xapianIndexNeedsUpdating() returning false when there is no index
at all.

CCMAIL:839411 at bugs.launchpad.net

M  +8    -2    src/backend.cpp

http://commits.kde.org/libqapt/e4090ffc906e3543c4e64e2afee64a02e71a53b1

diff --git a/src/backend.cpp b/src/backend.cpp
index acefd77..6d421e3 100644
--- a/src/backend.cpp
+++ b/src/backend.cpp
@@ -94,6 +94,7 @@ public:
     // Xapian
     time_t xapianTimeStamp;
     Xapian::Database xapianDatabase;
+    bool xapianIndexExists;
 
     // DBus
     QDBusServiceWatcher *watcher;
@@ -642,12 +643,14 @@ bool Backend::xapianIndexNeedsUpdate() const
    // If the cache has been modified after the xapian timestamp, we need to rebuild
    QDateTime aptCacheTime = QFileInfo(QLatin1String(_config->FindFile("Dir::Cache::pkgcache").c_str())).lastModified();
    QDateTime dpkgStatusTime = QFileInfo(QLatin1String("/var/lib/dpkg/status")).lastModified();
+
+   bool outdated = false;
    if (d->xapianTimeStamp < aptCacheTime.toTime_t() ||
        d->xapianTimeStamp < dpkgStatusTime.toTime_t()) {
-      return true;
+       outdated = true;
    }
 
-   return false;
+   return (outdated || (!d->xapianIndexExists));
 }
 
 bool Backend::openXapianIndex()
@@ -660,9 +663,12 @@ bool Backend::openXapianIndex()
     try {
         d->xapianDatabase.add_database(Xapian::Database("/var/lib/apt-xapian-index/index"));
     } catch (Xapian::DatabaseOpeningError) {
+        d->xapianIndexExists = false;
         return false;
     };
 
+    d->xapianIndexExists = true;
+
     return true;
 }

-- 
You received this bug notification because you are a member of Kubuntu
Bugs, which is subscribed to qapt in Ubuntu.
https://bugs.launchpad.net/bugs/839411

Title:
  initial install can not search

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/qapt/+bug/839411/+subscriptions




More information about the kubuntu-bugs mailing list