Minor number changes to the DBVERSION are intended to produce sqlite files
readable by yum versions which support the same major number DBVERSION. Add
this behaviour for reading sqlite databases.
---
 db.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/db.c b/db.c
index 019faac..69a8927 100644
--- a/db.c
+++ b/db.c
@@ -117,6 +117,13 @@ typedef enum {
     DB_STATUS_ERROR
 } DBStatus;
 
+static gboolean
+is_valid_dbversion(double ourver, double dbver)
+{
+    return (int) ourver == (int) dbver && dbver >= ourver &&
+        dbver - ourver < 1;
+}
+
 static DBStatus
 dbinfo_status (sqlite3 *db, const char *checksum)
 {
@@ -131,14 +138,14 @@ dbinfo_status (sqlite3 *db, const char *checksum)
         goto cleanup;
 
     while ((rc = sqlite3_step (handle)) == SQLITE_ROW) {
-        int dbversion;
+        double dbversion;
         const char *dbchecksum;
 
-        dbversion  = sqlite3_column_int  (handle, 0);
+        dbversion  = sqlite3_column_double  (handle, 0);
         dbchecksum = (const char *) sqlite3_column_text (handle, 1);
 
-        if (dbversion != YUM_SQLITE_CACHE_DBVERSION) {
-            g_message ("Warning: cache file is version %d, we need %d, will 
regenerate",
+        if (!is_valid_dbversion(dbversion, YUM_SQLITE_CACHE_DBVERSION)) {
+            g_message ("Warning: cache file is version %f, we need %d, will 
regenerate",
                        dbversion, YUM_SQLITE_CACHE_DBVERSION);
             status = DB_STATUS_VERSION_MISMATCH;
         } else if (strcmp (checksum, dbchecksum)) {
-- 
1.5.3.rc0.790.g0537d

Attachment: pgpze9iovwjXc.pgp
Description: PGP signature

_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to