From 433da92e374d8924abda3b78b6652971870b9697 Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Tue, 28 Jun 2011 15:40:52 +0300 Subject: index: handle errors instead of silently failing Make indexer keep noise about errors that prevent index generation. Detect certain errors in the APKs better. And also have the applet return error in these scenarios. --- src/database.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/database.c') diff --git a/src/database.c b/src/database.c index 9617b4e..9a977f4 100644 --- a/src/database.c +++ b/src/database.c @@ -1005,8 +1005,11 @@ static int apk_db_index_write_nr_cache(struct apk_database *db) int apk_db_index_write(struct apk_database *db, struct apk_ostream *os) { struct index_write_ctx ctx = { os, 0, FALSE }; + int r; - apk_hash_foreach(&db->available.packages, write_index_entry, &ctx); + r = apk_hash_foreach(&db->available.packages, write_index_entry, &ctx); + if (r < 0) + return r; return ctx.count; } @@ -1634,9 +1637,11 @@ static int load_apkindex(void *sctx, const struct apk_file_info *fi, struct apkindex_ctx *ctx = (struct apkindex_ctx *) sctx; struct apk_bstream *bs; struct apk_repository *repo; + int r; - if (apk_sign_ctx_process_file(&ctx->sctx, fi, is) == 0) - return 0; + r = apk_sign_ctx_process_file(&ctx->sctx, fi, is); + if (r <= 0) + return r; repo = &ctx->db->repos[ctx->repo]; @@ -1819,12 +1824,14 @@ static int apk_db_install_archive_entry(void *_ctx, apk_blob_t name = APK_BLOB_STR(ae->name), bdir, bfile; struct apk_db_dir_instance *diri = ctx->diri; struct apk_db_file *file; - int r = 0, type = APK_SCRIPT_INVALID; + int r, type = APK_SCRIPT_INVALID; - if (apk_sign_ctx_process_file(&ctx->sctx, ae, is) == 0) - return 0; + r = apk_sign_ctx_process_file(&ctx->sctx, ae, is); + if (r <= 0) + return r; /* Package metainfo and script processing */ + r = 0; if (ae->name[0] == '.') { /* APK 2.0 format */ if (strcmp(ae->name, ".PKGINFO") == 0) { -- cgit v1.2.3-60-g2f50