summaryrefslogtreecommitdiff
path: root/src/package.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-01-11 09:56:42 +0200
committerTimo Teräs <timo.teras@iki.fi>2020-01-11 11:32:51 +0200
commitf123d77e0b903b7459296291e04b6558ceb4c287 (patch)
tree75cc6e28f5f3d86d63922762072a3392d2bb81cb /src/package.c
parent1de9ef422c087ee8fc302c9d889dd373dc6dde58 (diff)
downloadapk-tools-f123d77e0b903b7459296291e04b6558ceb4c287.tar.gz
apk-tools-f123d77e0b903b7459296291e04b6558ceb4c287.tar.bz2
apk-tools-f123d77e0b903b7459296291e04b6558ceb4c287.tar.xz
apk-tools-f123d77e0b903b7459296291e04b6558ceb4c287.zip
archive: make apk_tar_parse check and close input stream
simplifies other code quite a bit
Diffstat (limited to 'src/package.c')
-rw-r--r--src/package.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/package.c b/src/package.c
index cbcdfce..3b7c6bd 100644
--- a/src/package.c
+++ b/src/package.c
@@ -904,7 +904,6 @@ int apk_pkg_read(struct apk_database *db, const char *file,
{
struct read_info_ctx ctx;
struct apk_file_info fi;
- struct apk_istream *is, *tar;
int r;
r = apk_fileinfo_get(AT_FDCWD, file, APK_CHECKSUM_NONE, &fi);
@@ -912,23 +911,18 @@ int apk_pkg_read(struct apk_database *db, const char *file,
return r;
memset(&ctx, 0, sizeof(ctx));
+ ctx.db = db;
ctx.sctx = sctx;
ctx.pkg = apk_pkg_new();
r = -ENOMEM;
if (ctx.pkg == NULL)
goto err;
- is = apk_istream_from_file(AT_FDCWD, file);
- if (IS_ERR_OR_NULL(is)) {
- r = PTR_ERR(is) ?: -EIO;
- goto err;
- }
- ctx.db = db;
ctx.pkg->size = fi.size;
- tar = apk_istream_gunzip_mpart(is, apk_sign_ctx_mpart_cb, sctx);
- r = apk_tar_parse(tar, read_info_entry, &ctx, &db->id_cache);
- apk_istream_close(tar);
+ r = apk_tar_parse(
+ apk_istream_gunzip_mpart(apk_istream_from_file(AT_FDCWD, file), apk_sign_ctx_mpart_cb, sctx),
+ read_info_entry, &ctx, &db->id_cache);
if (r < 0 && r != -ECANCELED)
goto err;
if (ctx.pkg->name == NULL || ctx.pkg->uninstallable) {