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-03-21 16:43:15 +0200
commit27291bd5fcd6e069551f82865ec3fc3de69a4239 (patch)
treee1ff6f71b43cc4cc2c8a5102815298ce9be9b38a
parentc1d34a07f45cd6e8d6ddc98e40390e86c7268201 (diff)
downloadapk-tools-27291bd5fcd6e069551f82865ec3fc3de69a4239.tar.gz
apk-tools-27291bd5fcd6e069551f82865ec3fc3de69a4239.tar.bz2
apk-tools-27291bd5fcd6e069551f82865ec3fc3de69a4239.tar.xz
apk-tools-27291bd5fcd6e069551f82865ec3fc3de69a4239.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 1f05a80..f9fdcf1 100644
--- a/src/app_fetch.c
+++ b/src/app_fetch.c
@@ -191,10 +191,10 @@ static int fetch_package(struct apk_database *db, const char *match, struct apk_
os = apk_ostream_to_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;
}
os = apk_ostream_to_file(ctx->outdir_fd, filename, 0644);
if (IS_ERR(os)) {
@@ -214,13 +214,13 @@ static int fetch_package(struct apk_database *db, const char *match, struct apk_
apk_istream_close(is);
r = apk_ostream_close(os);
if (r) goto err;
-
- ctx->done += pkg->size;
- return 0;
+ goto done;
err:
apk_err(out, PKG_VER_FMT ": %s", PKG_VER_PRINTF(pkg), apk_error_str(r));
ctx->errors++;
+done:
+ ctx->done += pkg->size;
return 0;
}