summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2023-03-21 15:06:54 +0200
committerTimo Teräs <timo.teras@iki.fi>2023-04-11 20:55:13 +0300
commit6c2af0f0d3381f1a2d12105e310ae47e120f5d4d (patch)
tree5e0da3f2bac718bc37a6f37ae4802434e238775b
parent78b70cd6e865b252a2019512724b4e56687eacc1 (diff)
downloadapk-tools-6c2af0f0d3381f1a2d12105e310ae47e120f5d4d.tar.gz
apk-tools-6c2af0f0d3381f1a2d12105e310ae47e120f5d4d.tar.bz2
apk-tools-6c2af0f0d3381f1a2d12105e310ae47e120f5d4d.tar.xz
apk-tools-6c2af0f0d3381f1a2d12105e310ae47e120f5d4d.zip
fetch: improve --link handling
Handle file: URLs correctly, and don't do linkat() syscall if it is a remote repository. Also account the file size to progress always.
-rw-r--r--src/app_fetch.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/app_fetch.c b/src/app_fetch.c
index a94a67c..6b40786 100644
--- a/src/app_fetch.c
+++ b/src/app_fetch.c
@@ -188,10 +188,10 @@ static int fetch_package(struct apk_database *db, const char *match, struct apk_
fd = STDOUT_FILENO;
} else {
if ((ctx->flags & FETCH_LINK) && urlfd >= 0) {
- if (linkat(urlfd, url,
- ctx->outdir_fd, filename,
- AT_SYMLINK_FOLLOW) == 0)
- return 0;
+ const char *urlfile = apk_url_local_file(url);
+ if (urlfile &&
+ linkat(urlfd, urlfile, ctx->outdir_fd, filename, AT_SYMLINK_FOLLOW) == 0)
+ goto done;
}
fd = openat(ctx->outdir_fd, filename,
O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC, 0644);
@@ -221,13 +221,13 @@ static int fetch_package(struct apk_database *db, const char *match, struct apk_
if (r >= 0) r = -EIO;
goto err;
}
-
- ctx->done += pkg->size;
- return 0;
+ goto done;
err:
apk_error(PKG_VER_FMT ": %s", PKG_VER_PRINTF(pkg), apk_error_str(r));
ctx->errors++;
+done:
+ ctx->done += pkg->size;
return 0;
}