summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2023-04-12 12:45:57 +0300
committerTimo Teräs <timo.teras@iki.fi>2023-04-12 12:45:57 +0300
commit01821c845f355220b57719f12849428fa1f08741 (patch)
tree04c2122912e54d6c986ab28559899a44e97734f2
parent6650b02529a32e3516830b2fe75750ef0c489ca7 (diff)
downloadapk-tools-01821c845f355220b57719f12849428fa1f08741.tar.gz
apk-tools-01821c845f355220b57719f12849428fa1f08741.tar.bz2
apk-tools-01821c845f355220b57719f12849428fa1f08741.tar.xz
apk-tools-01821c845f355220b57719f12849428fa1f08741.zip
db, index: clean up index writing error handling
-rw-r--r--src/app_index.c34
-rw-r--r--src/database.c4
2 files changed, 17 insertions, 21 deletions
diff --git a/src/app_index.c b/src/app_index.c
index 80fd8e2..7281565 100644
--- a/src/app_index.c
+++ b/src/app_index.c
@@ -265,31 +265,29 @@ static int index_main(void *ctx, struct apk_database *db, struct apk_string_arra
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);
- }
+ 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_tar_write_entry(os, &fi, NULL);
- r = index_write(ictx, db, os);
- apk_tar_write_padding(os, &fi);
+ 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);
- }
+ apk_tar_write_entry(os, NULL, NULL);
} else {
- r = index_write(ictx, db, os);
+ index_write(ictx, db, os);
}
- apk_ostream_close(os);
+ r = apk_ostream_close(os);
if (r < 0) {
apk_error("Index generation failed: %s", apk_error_str(r));
return r;
diff --git a/src/database.c b/src/database.c
index ba53ecb..da77b07 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1208,7 +1208,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;
@@ -1225,8 +1224,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);