poldek: poldek/pkgdir/pkgdir_dirindex.c - dirindex update was broken

mis mis at pld-linux.org
Sat Jun 23 02:34:54 CEST 2007


Author: mis                          Date: Sat Jun 23 00:34:54 2007 GMT
Module: poldek                        Tag: HEAD
---- Log message:
- dirindex update was broken

---- Files affected:
poldek/poldek/pkgdir:
   pkgdir_dirindex.c (1.10 -> 1.11) 

---- Diffs:

================================================================
Index: poldek/poldek/pkgdir/pkgdir_dirindex.c
diff -u poldek/poldek/pkgdir/pkgdir_dirindex.c:1.10 poldek/poldek/pkgdir/pkgdir_dirindex.c:1.11
--- poldek/poldek/pkgdir/pkgdir_dirindex.c:1.10	Thu Jun 21 18:41:40 2007
+++ poldek/poldek/pkgdir/pkgdir_dirindex.c	Sat Jun 23 02:34:49 2007
@@ -68,7 +68,7 @@
 
 static
 const char **get_package_directories(struct tndb *db, const char *key, int klen,
-                                     char *val, int vsize, int *ndirs);
+                                     char *val, int *vsize, int *ndirs);
 
 
 /* package_no as db key */
@@ -135,7 +135,7 @@
                                tn_hash *path_index, struct pkgdir_dirindex *dirindex)
 {
     const char **tl, **tl_save;
-    char key[512], val[16 * 1024];
+    char key[512], val[32 * 1024];
     int klen, vlen, found = 0, ndirs;
 
     n_assert(dirindex);
@@ -143,26 +143,30 @@
     klen = package_key(key, sizeof(key), pkg, PREFIX_PKGKEY_REQDIR);
 
     if (n_hash_exists(dirindex->keymap, &key[2])) { /* got it */
-        DBGF("HIT %s\n", pkg_id(pkg));
+        DBGF("HIT %s %s\n", pkg_id(pkg), key);
         found = 1;
     }
-    
+  
+    /* requires any directories? */
     if ((vlen = tndb_get(dirindex->db, key, klen, val, sizeof(val))) > 0)
         tndb_put(db, key, klen, val, vlen);
 
     key[1] = PREFIX_PKGKEY_OWNDIR;
 
 
-    tl = tl_save = get_package_directories(dirindex->db, key, klen, val, sizeof(val),
-                                           &ndirs);
+    vlen = sizeof(val);
+    tl = tl_save = get_package_directories(dirindex->db, key, klen, val, &vlen, 
+		                           &ndirs);
 
-    if (tl == NULL)
+    if (tl == NULL) /* without owned directories */
         return found;
-    
+
+    n_assert(vlen > 0); 
     tndb_put(db, key, klen, val, vlen);
-        
+
     while (*tl) {
         const char *dir = *tl;
+        dir = dir + 1; /* skip '/' */
         add_to_path_index(path_index, dir, package_no);
         tl++;
     }
@@ -268,7 +272,7 @@
     
     if ((lock = vf_lock_mkdir(dir)) == NULL)
         return 0;
-
+    
     db = tndb_creat(path, 0, TNDB_SIGN_DIGEST);
 
     if (db == NULL) {
@@ -421,16 +425,17 @@
 
 static
 const char **get_package_directories(struct tndb *db, const char *key, int klen,
-                                      char *val, int vsize, int *ndirs)
+                                      char *val, int *vsize, int *ndirs)
 {
     const char **tl;
     int vlen;
     
-    if ((vlen = tndb_get(db, key, klen, val, vsize)) == 0)
+    if ((vlen = tndb_get(db, key, klen, val, *vsize)) == 0)
         return NULL;
 
     n_assert(vlen < vsize);
     val[vlen] = '\0';
+    *vsize = vlen;
 
     *ndirs = 0;
     tl = n_str_tokl_n(val, ":", ndirs);
@@ -496,10 +501,11 @@
 {
     const char **tl, **tl_save;
     char val[16 * 1024];
-    int  n = 0, nadded = 0;
+    int  vlen, n = 0, nadded = 0;
 
     n_assert(key[1] == PREFIX_PKGKEY_REQDIR);
-    tl = tl_save = get_package_directories(db, key, klen, val, sizeof(val), &n);
+    vlen = sizeof(val);
+    tl = tl_save = get_package_directories(db, key, klen, val, &vlen, &n);
     if (tl == NULL)
         return 0;
     
@@ -562,7 +568,7 @@
             n_hash_replace(idmap, pkg_no, pkg_link(pkg));
             
         } else if (flags & UPDATE_IFNEEDED) {
-            msgn_i(3, 4, "directory index outdated, trying to update...");
+            msgn_i(3, 4, "%s: missing package", pkg_id(pkg));
             index_outdated = 1;
             
         } else {
@@ -681,12 +687,12 @@
 {
     const char  **tl, **tl_save;
     char        key[512], val[1024 * 4];
-    int         klen, n = 0;
+    int         klen, vlen, n = 0;
     tn_array    *dirs;
     
-    
+    vlen = sizeof(val);
     klen = package_key(key, sizeof(key), pkg, PREFIX_PKGKEY_REQDIR);
-    tl = tl_save = get_package_directories(dirindex->db, key, klen, val, sizeof(val), &n);
+    tl = tl_save = get_package_directories(dirindex->db, key, klen, val, &vlen, &n);
     if (tl == NULL)
         return NULL;
         
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/poldek/poldek/pkgdir/pkgdir_dirindex.c?r1=1.10&r2=1.11&f=u



More information about the pld-cvs-commit mailing list