@@ -847,16 +847,14 @@ collect_data_cb(void *vcbdata, Solvable *s, Repodata *data, Repokey *key, KeyVal
847847 if (cbdata -> owndirpool )
848848 id = putinowndirpool (cbdata , data , id );
849849 id = cbdata -> dirused [id ];
850- if (cbdata -> filelistmode > 0 )
850+ if (cbdata -> filelistmode )
851851 {
852- /* postpone adding to xd, just update len */
852+ /* postpone adding to xd, just update len to get the correct offsets into the incore data */
853853 xd -> len += data_addideof_len (id ) + strlen (kv -> str ) + 1 ;
854854 break ;
855855 }
856856 data_addideof (xd , id , kv -> eof );
857857 data_addblob (xd , (unsigned char * )kv -> str , strlen (kv -> str ) + 1 );
858- if (cbdata -> filelistmode < 0 ) /* in second pass of filelist mode */
859- return 0 ;
860858 break ;
861859 case REPOKEY_TYPE_FIXARRAY :
862860 case REPOKEY_TYPE_FLEXARRAY :
@@ -885,7 +883,29 @@ collect_data_cb(void *vcbdata, Solvable *s, Repodata *data, Repokey *key, KeyVal
885883 return 0 ;
886884}
887885
888- void
886+ /* special version of collect_data_cb that collects just one single REPOKEY_TYPE_DIRSTRARRAY vertical data */
887+ static int
888+ collect_filelist_cb (void * vcbdata , Solvable * s , Repodata * data , Repokey * key , KeyValue * kv )
889+ {
890+ struct cbdata * cbdata = vcbdata ;
891+ int rm ;
892+ Id id ;
893+ struct extdata * xd ;
894+
895+ rm = cbdata -> keymap [key - data -> keys ];
896+ if (!rm )
897+ return SEARCH_NEXT_KEY ; /* we do not want this one */
898+ id = kv -> id ;
899+ if (cbdata -> owndirpool )
900+ id = putinowndirpool (cbdata , data , id );
901+ id = cbdata -> dirused [id ];
902+ xd = cbdata -> extdata + rm ; /* vertical buffer */
903+ data_addideof (xd , id , kv -> eof );
904+ data_addblob (xd , (unsigned char * )kv -> str , strlen (kv -> str ) + 1 );
905+ return 0 ;
906+ }
907+
908+ static void
889909collect_data_solvable (struct cbdata * cbdata , Solvable * s , Id * keymap )
890910{
891911 Repo * repo = s -> repo ;
@@ -1215,7 +1235,8 @@ repowriter_write(Repowriter *writer, FILE *fp)
12151235
12161236 struct extdata * xd ;
12171237
1218- Id type_constantid = REPOKEY_TYPE_CONSTANTID ;
1238+ Id type_constantid = 0 ;
1239+ Id type_dirstrarray = 0 ;
12191240
12201241
12211242 memset (& cbdata , 0 , sizeof (cbdata ));
@@ -1370,7 +1391,7 @@ repowriter_write(Repowriter *writer, FILE *fp)
13701391 continue ;
13711392 }
13721393 }
1373- if (data -> state != REPODATA_AVAILABLE )
1394+ if (data -> state != REPODATA_AVAILABLE && data -> state != REPODATA_LOADING )
13741395 {
13751396 /* too bad! */
13761397 keymap [n ] = 0 ;
@@ -1482,18 +1503,24 @@ for (i = 1; i < target.nkeys; i++)
14821503 for (i = 1 , key = target .keys + i ; i < target .nkeys ; i ++ , key ++ )
14831504 {
14841505 key -> name = stringpool_str2id (spool , pool_id2str (pool , key -> name ), 1 );
1506+ id = stringpool_str2id (spool , pool_id2str (pool , key -> type ), 1 );
14851507 if (key -> type == REPOKEY_TYPE_CONSTANTID )
14861508 {
1487- key -> type = stringpool_str2id (spool , pool_id2str (pool , key -> type ), 1 );
1488- type_constantid = key -> type ;
1509+ type_constantid = id ;
14891510 key -> size = stringpool_str2id (spool , pool_id2str (pool , key -> size ), 1 );
14901511 }
1491- else
1492- key -> type = stringpool_str2id (spool , pool_id2str (pool , key -> type ), 1 );
1512+ if (key -> type == REPOKEY_TYPE_DIRSTRARRAY )
1513+ type_dirstrarray = id ;
1514+ key -> type = id ;
14931515 }
14941516 if (poolusage == 2 )
14951517 stringpool_freehash (spool ); /* free some mem */
14961518 }
1519+ else
1520+ {
1521+ type_constantid = REPOKEY_TYPE_CONSTANTID ;
1522+ type_dirstrarray = REPOKEY_TYPE_DIRSTRARRAY ;
1523+ }
14971524
14981525
14991526/********************************************************************/
@@ -1818,8 +1845,8 @@ fprintf(stderr, "dir %d used %d\n", i, cbdata.dirused ? cbdata.dirused[i] : 1);
18181845 {
18191846 for (i = 1 ; i < target .nkeys ; i ++ )
18201847 if (target .keys [i ].storage == KEY_STORAGE_VERTICAL_OFFSET )
1821- cbdata .filelistmode |= cbdata .filelistmode == 0 && target .keys [i ].type == REPOKEY_TYPE_DIRSTRARRAY ? 1 : 2 ;
1822- else if (target .keys [i ].type == REPOKEY_TYPE_DIRSTRARRAY )
1848+ cbdata .filelistmode |= cbdata .filelistmode == 0 && target .keys [i ].type == type_dirstrarray ? 1 : 2 ;
1849+ else if (target .keys [i ].type == type_dirstrarray )
18231850 cbdata .filelistmode = 2 ;
18241851 if (cbdata .filelistmode != 1 )
18251852 cbdata .filelistmode = 0 ;
@@ -1997,10 +2024,10 @@ fprintf(stderr, "dir %d used %d\n", i, cbdata.dirused ? cbdata.dirused[i] : 1);
19972024 }
19982025 else
19992026 {
2000- /* ok, just this single extdata, which is a filelist */
2027+ /* ok, just this single extdata, which is of type REPOKEY_TYPE_DIRSTRARRAY */
20012028 xd = cbdata .extdata + i ;
20022029 xd -> len = 0 ;
2003- cbdata . filelistmode = -1 ; /* mark that we are writing */
2030+ /* remove all keys from the keymap but this one */
20042031 for (j = 0 ; j < nkeymap ; j ++ )
20052032 if (keymap [j ] != i )
20062033 keymap [j ] = 0 ;
@@ -2015,7 +2042,7 @@ fprintf(stderr, "dir %d used %d\n", i, cbdata.dirused ? cbdata.dirused[i] : 1);
20152042 continue ;
20162043 cbdata .keymap = keymap + keymapstart [j ];
20172044 cbdata .lastdirid = 0 ;
2018- repodata_search_keyskip (data , i , 0 , searchflags , keyskip , collect_data_cb , & cbdata );
2045+ repodata_search_keyskip (data , i , 0 , searchflags , keyskip , collect_filelist_cb , & cbdata );
20192046 }
20202047 if (xd -> len > 1024 * 1024 )
20212048 {
0 commit comments