Move key size fixups from rpmdbAdd & Remove to td2key()
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 28 May 2008 06:53:30 +0000 (09:53 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 28 May 2008 06:53:30 +0000 (09:53 +0300)
lib/rpmdb.c

index 3a00cfe..6a3799e 100644 (file)
@@ -2396,6 +2396,12 @@ static int td2key(rpmtd tagdata, DBT *key)
        key->size = strlen(str);
        break;
     }
+
+    if (key->size == 0) 
+       key->size = strlen((char *)key->data);
+    if (key->size == 0) 
+       key->size++;    /* XXX "/" fixup. */
+
     return 1;
 }
 
@@ -2531,11 +2537,6 @@ int rpmdbRemove(rpmdb db, int rid, unsigned int hdrNum,
                 * */
                set = NULL;
 
-               if (key.size == 0) 
-                   key.size = strlen((char *)key.data);
-               if (key.size == 0) 
-                   key.size++; /* XXX "/" fixup. */
                rc = dbiGet(dbi, dbcursor, &key, &data, DB_SET);
                if (rc == 0) {                  /* success */
                    (void) dbt2set(dbi, &data, &set);
@@ -2831,11 +2832,6 @@ int rpmdbAdd(rpmdb db, int iid, Header h,
 
                set = NULL;
 
-               if (key.size == 0) 
-                   key.size = strlen((char *)key.data);
-               if (key.size == 0) 
-                   key.size++; /* XXX "/" fixup. */
-
                rc = dbiGet(dbi, dbcursor, &key, &data, DB_SET);
                if (rc == 0) {                  /* success */
                /* With duplicates, cursor is positioned, discard the record. */