Skip to content

Commit 5bd0f26

Browse files
committed
repo_write: fix handling of nested flexarray
Fixes issue #402
1 parent 7046fb0 commit 5bd0f26

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

src/repo_write.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -570,25 +570,29 @@ collect_needed_cb(void *vcbdata, Solvable *s, Repodata *data, Repokey *key, KeyV
570570
break;
571571
case REPOKEY_TYPE_FIXARRAY:
572572
case REPOKEY_TYPE_FLEXARRAY:
573-
if (kv->entry == 0)
573+
if (kv->entry)
574574
{
575-
if (kv->eof != 2)
576-
*cbdata->sp++ = 0; /* mark start */
577-
}
578-
else
579-
{
580-
/* just finished a schema, rewind to start */
575+
/* finish schema, rewind to start */
581576
Id *sp = cbdata->sp - 1;
582577
*sp = 0;
583578
while (sp[-1])
584579
sp--;
585-
if (kv->entry == 1 || key->type == REPOKEY_TYPE_FLEXARRAY)
580+
if (sp[-2] >= 0)
581+
cbdata->subschemata[sp[-2]] = repodata_schema2id(cbdata->target, sp, 1);
582+
cbdata->sp = sp - 2;
583+
}
584+
if (kv->eof != 2)
585+
{
586+
/* start new schema */
587+
if (kv->entry == 0 || key->type == REPOKEY_TYPE_FLEXARRAY)
586588
{
587589
cbdata->subschemata = solv_extend(cbdata->subschemata, cbdata->nsubschemata, 1, sizeof(Id), SCHEMATA_BLOCK);
588-
cbdata->subschemata[cbdata->nsubschemata++] = repodata_schema2id(cbdata->target, sp, 1);
590+
*cbdata->sp++ = cbdata->nsubschemata++;
589591
}
590-
cbdata->sp = kv->eof == 2 ? sp - 1: sp;
591-
}
592+
else
593+
*cbdata->sp++ = -1;
594+
*cbdata->sp++ = 0;
595+
}
592596
break;
593597
default:
594598
break;

0 commit comments

Comments
 (0)