xbps-repo: simplify 'index-files.plist', externalized as an array.
This commit is contained in:
parent
2186e16a5e
commit
95804bdb77
@ -86,8 +86,7 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd, struct ffdata *ffd)
|
||||
static int
|
||||
find_files_in_package(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
{
|
||||
prop_dictionary_t idxfilesd;
|
||||
prop_array_t files_keys;
|
||||
prop_array_t idxfiles;
|
||||
struct ffdata *ffd = arg;
|
||||
char *plist;
|
||||
unsigned int i;
|
||||
@ -99,18 +98,17 @@ find_files_in_package(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
if (plist == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
idxfilesd = prop_dictionary_internalize_from_zfile(plist);
|
||||
if (idxfilesd == NULL) {
|
||||
idxfiles = prop_array_internalize_from_zfile(plist);
|
||||
if (idxfiles == NULL) {
|
||||
free(plist);
|
||||
return errno;
|
||||
}
|
||||
free(plist);
|
||||
|
||||
files_keys = prop_dictionary_get(idxfilesd, "packages");
|
||||
for (i = 0; i < prop_array_count(files_keys); i++)
|
||||
match_files_by_pattern(prop_array_get(files_keys, i), ffd);
|
||||
for (i = 0; i < prop_array_count(idxfiles); i++)
|
||||
match_files_by_pattern(prop_array_get(idxfiles, i), ffd);
|
||||
|
||||
prop_object_release(idxfilesd);
|
||||
prop_object_release(idxfiles);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ genindex_files_cb(prop_object_t obj, void *arg, bool *done)
|
||||
int
|
||||
repo_genindex_files(const char *pkgdir)
|
||||
{
|
||||
prop_dictionary_t idxdict, idxfilesd;
|
||||
prop_dictionary_t idxdict;
|
||||
struct index_files_data *ifd;
|
||||
char *plist, *files_plist;
|
||||
int rv;
|
||||
@ -164,31 +164,20 @@ repo_genindex_files(const char *pkgdir)
|
||||
free(ifd);
|
||||
return rv;
|
||||
}
|
||||
idxfilesd = prop_dictionary_create();
|
||||
/* add array into the index-files dictionary */
|
||||
if (!prop_dictionary_set(idxfilesd, "packages", ifd->idxfiles)) {
|
||||
prop_object_release(ifd->idxfiles);
|
||||
prop_object_release(idxfilesd);
|
||||
free(ifd);
|
||||
return EINVAL;
|
||||
}
|
||||
files_plist = xbps_pkg_index_files_plist(pkgdir);
|
||||
if (files_plist == NULL) {
|
||||
prop_object_release(ifd->idxfiles);
|
||||
prop_object_release(idxfilesd);
|
||||
free(ifd);
|
||||
return ENOMEM;
|
||||
}
|
||||
/* externalize index-files dictionary to the plist file */
|
||||
if (!prop_dictionary_externalize_to_zfile(idxfilesd, files_plist)) {
|
||||
if (!prop_array_externalize_to_zfile(ifd->idxfiles, files_plist)) {
|
||||
free(files_plist);
|
||||
prop_object_release(ifd->idxfiles);
|
||||
prop_object_release(idxfilesd);
|
||||
free(ifd);
|
||||
return errno;
|
||||
}
|
||||
free(files_plist);
|
||||
prop_object_release(idxfilesd);
|
||||
prop_object_release(ifd->idxfiles);
|
||||
free(ifd);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user