xbps-repo: simplify 'index-files.plist', externalized as an array.

This commit is contained in:
Juan RP 2012-01-15 16:33:44 +01:00
parent 2186e16a5e
commit 95804bdb77
2 changed files with 8 additions and 21 deletions

View File

@ -86,8 +86,7 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd, struct ffdata *ffd)
static int static int
find_files_in_package(struct repository_pool_index *rpi, void *arg, bool *done) find_files_in_package(struct repository_pool_index *rpi, void *arg, bool *done)
{ {
prop_dictionary_t idxfilesd; prop_array_t idxfiles;
prop_array_t files_keys;
struct ffdata *ffd = arg; struct ffdata *ffd = arg;
char *plist; char *plist;
unsigned int i; unsigned int i;
@ -99,18 +98,17 @@ find_files_in_package(struct repository_pool_index *rpi, void *arg, bool *done)
if (plist == NULL) if (plist == NULL)
return ENOMEM; return ENOMEM;
idxfilesd = prop_dictionary_internalize_from_zfile(plist); idxfiles = prop_array_internalize_from_zfile(plist);
if (idxfilesd == NULL) { if (idxfiles == NULL) {
free(plist); free(plist);
return errno; return errno;
} }
free(plist); free(plist);
files_keys = prop_dictionary_get(idxfilesd, "packages"); for (i = 0; i < prop_array_count(idxfiles); i++)
for (i = 0; i < prop_array_count(files_keys); i++) match_files_by_pattern(prop_array_get(idxfiles, i), ffd);
match_files_by_pattern(prop_array_get(files_keys, i), ffd);
prop_object_release(idxfilesd); prop_object_release(idxfiles);
return 0; return 0;
} }

View File

@ -127,7 +127,7 @@ genindex_files_cb(prop_object_t obj, void *arg, bool *done)
int int
repo_genindex_files(const char *pkgdir) repo_genindex_files(const char *pkgdir)
{ {
prop_dictionary_t idxdict, idxfilesd; prop_dictionary_t idxdict;
struct index_files_data *ifd; struct index_files_data *ifd;
char *plist, *files_plist; char *plist, *files_plist;
int rv; int rv;
@ -164,31 +164,20 @@ repo_genindex_files(const char *pkgdir)
free(ifd); free(ifd);
return rv; 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); files_plist = xbps_pkg_index_files_plist(pkgdir);
if (files_plist == NULL) { if (files_plist == NULL) {
prop_object_release(ifd->idxfiles); prop_object_release(ifd->idxfiles);
prop_object_release(idxfilesd);
free(ifd); free(ifd);
return ENOMEM; return ENOMEM;
} }
/* externalize index-files dictionary to the plist file */ /* 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); free(files_plist);
prop_object_release(ifd->idxfiles); prop_object_release(ifd->idxfiles);
prop_object_release(idxfilesd);
free(ifd); free(ifd);
return errno; return errno;
} }
free(files_plist); free(files_plist);
prop_object_release(idxfilesd);
prop_object_release(ifd->idxfiles); prop_object_release(ifd->idxfiles);
free(ifd); free(ifd);