diff --git a/src/app_index.c b/src/app_index.c index 02fe30d1c6eca14b701e67deebf2c02887fae367..65e1fba5a66b2652489a833e963641883d47696a 100644 --- a/src/app_index.c +++ b/src/app_index.c @@ -260,28 +260,25 @@ static int index_main(void *ctx, struct apk_ctx *ac, struct apk_string_array *ar fi.mode = 0644 | S_IFREG; fi.name = "APKINDEX"; counter = apk_ostream_counter(&fi.size); - r = index_write(ictx, db, counter); + index_write(ictx, db, counter); apk_ostream_close(counter); - if (r >= 0) { - os = apk_ostream_gzip(os); - if (ictx->description != NULL) { - struct apk_file_info fi_desc; - memset(&fi_desc, 0, sizeof(fi)); - fi_desc.mode = 0644 | S_IFREG; - fi_desc.name = "DESCRIPTION"; - fi_desc.size = strlen(ictx->description); - apk_tar_write_entry(os, &fi_desc, ictx->description); - } - - apk_tar_write_entry(os, &fi, NULL); - r = index_write(ictx, db, os); - apk_tar_write_padding(os, &fi); - - apk_tar_write_entry(os, NULL, NULL); + os = apk_ostream_gzip(os); + if (ictx->description) { + struct apk_file_info fi_desc; + memset(&fi_desc, 0, sizeof(fi)); + fi_desc.mode = 0644 | S_IFREG; + fi_desc.name = "DESCRIPTION"; + fi_desc.size = strlen(ictx->description); + apk_tar_write_entry(os, &fi_desc, ictx->description); } - apk_ostream_close(os); + apk_tar_write_entry(os, &fi, NULL); + index_write(ictx, db, os); + apk_tar_write_padding(os, &fi); + apk_tar_write_entry(os, NULL, NULL); + + r = apk_ostream_close(os); if (r < 0) { apk_err(out, "Index generation failed: %s", apk_error_str(r)); return r; diff --git a/src/database.c b/src/database.c index 3c50389246e310711bb8bc9d33d6a1b01895ffa5..e311953349ebd25cfbde0978648622f7472307d8 100644 --- a/src/database.c +++ b/src/database.c @@ -1243,7 +1243,6 @@ static int apk_db_index_write_nr_cache(struct apk_database *db) struct apk_package_array *pkgs; struct apk_package **ppkg; struct apk_ostream *os; - int r; if (!apk_db_cache_active(db)) return 0; @@ -1257,8 +1256,7 @@ static int apk_db_index_write_nr_cache(struct apk_database *db) struct apk_package *pkg = *ppkg; if ((pkg->repos == BIT(APK_REPOSITORY_CACHED) || (pkg->repos == 0 && !pkg->installed_size))) { - r = apk_pkg_write_index_entry(pkg, os); - if (r != 0) return r; + if (apk_pkg_write_index_entry(pkg, os) < 0) break; } } return apk_ostream_close(os);