]> git.ipfire.org Git - pakfire.git/commitdiff
xfer: Only have one way to create a new xfer
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 19:09:19 +0000 (19:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 19:09:19 +0000 (19:09 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/buildservice.c
src/libpakfire/daemon.c
src/libpakfire/dist.c
src/libpakfire/include/pakfire/xfer.h
src/libpakfire/job.c
src/libpakfire/repo.c
src/libpakfire/xfer.c

index e1066cbdec16906dd25125c6d6fd4c1012927771..bc36523dea34e2a9064436a4be7c218605930357 100644 (file)
@@ -62,7 +62,7 @@ static int pakfire_buildservice_xfer_create(struct pakfire_xfer** xfer,
        va_start(args, url);
 
        // Create a new xfer
-       r = __pakfire_xfer_create(&x, service->ctx, url, args);
+       r = pakfire_xfer_create(&x, service->ctx, url, args);
        if (r < 0)
                goto ERROR;
 
index 27c166b1b7c04ab78e00bca0ac3fe5d77447498e..2061dfb8f339210c276ce1bee4847c347a63dfac 100644 (file)
@@ -493,12 +493,15 @@ static int pakfire_daemon_close(struct pakfire_xfer* xfer, int code, void* data)
 }
 
 static int pakfire_daemon_xfer_create(struct pakfire_xfer** xfer,
-               struct pakfire_daemon* daemon, const char* url) {
+               struct pakfire_daemon* daemon, const char* url, ...) {
        struct pakfire_xfer* x = NULL;
+       va_list args;
        int r;
 
+       va_start(args, url);
+
        // Create a new xfer
-       r = pakfire_xfer_create(&x, daemon->ctx, "%s", url);
+       r = pakfire_xfer_create(&x, daemon->ctx, url, args);
        if (r < 0)
                goto ERROR;
 
@@ -513,6 +516,7 @@ static int pakfire_daemon_xfer_create(struct pakfire_xfer** xfer,
 ERROR:
        if (x)
                pakfire_xfer_unref(x);
+       va_end(args);
 
        return r;
 }
index a81c9fa4751ae8a8bf0f81e32ff52a704a9661dd..4d14077784b8282804c9f75872b3bb7f65cdda25 100644 (file)
@@ -280,16 +280,19 @@ ERROR:
 }
 
 static int pakfire_dist_download_source(struct pakfire_ctx* ctx,
-               struct pakfire_mirrorlist* mirrorlist, const char* filename, const char* cache_path) {
+               struct pakfire_mirrorlist* mirrorlist, const char* cache_path, const char* filename, ...) {
        struct pakfire_xfer* xfer = NULL;
+       va_list args;
        int r;
 
        // Do not download if the file exists
        if (pakfire_path_exists(cache_path))
                return 0;
 
+       va_start(args, filename);
+
        // Create a new transfer
-       r = pakfire_xfer_create(&xfer, ctx, "%s", filename);
+       r = pakfire_xfer_create(&xfer, ctx, filename, args);
        if (r)
                goto ERROR;
 
@@ -311,6 +314,7 @@ static int pakfire_dist_download_source(struct pakfire_ctx* ctx,
 ERROR:
        if (xfer)
                pakfire_xfer_unref(xfer);
+       va_end(args);
 
        return r;
 }
@@ -330,7 +334,7 @@ static int pakfire_dist_add_source(struct pakfire* pakfire, struct pakfire_packa
                return r;
 
        // Download the source file
-       r = pakfire_dist_download_source(ctx, mirrorlist, filename, cache_path);
+       r = pakfire_dist_download_source(ctx, mirrorlist, cache_path, "%s", filename);
        if (r)
                return r;
 
index 60cbe8a48af334e9d32806ec0a988dbe7073947c..971285b818aa87a42d21ad401d431787dfbbd197 100644 (file)
@@ -81,9 +81,7 @@ typedef enum pakfire_transfer_method {
        PAKFIRE_METHOD_DELETE,
 } pakfire_xfer_method_t;
 
-int pakfire_xfer_create(struct pakfire_xfer** transfer, struct pakfire_ctx* ctx,
-       const char* url, ...) __attribute__((format(printf, 3, 4)));
-int __pakfire_xfer_create(struct pakfire_xfer** xfer, struct pakfire_ctx* ctx,
+int pakfire_xfer_create(struct pakfire_xfer** xfer, struct pakfire_ctx* ctx,
        const char* url, va_list args) __attribute__((format(printf, 3, 0)));
 
 struct pakfire_xfer* pakfire_xfer_ref(struct pakfire_xfer* xfer);
index 011183d48c22bafa368d3926b5a3ad6995a4cbfb..f41635c0ad2547be22553140efc1c83a2cebe2a3 100644 (file)
@@ -620,7 +620,7 @@ static int pakfire_job_xfer_create(struct pakfire_xfer** xfer,
        va_start(args, url);
 
        // Create a new xfer
-       r = __pakfire_xfer_create(&x, job->ctx, url, args);
+       r = pakfire_xfer_create(&x, job->ctx, url, args);
        if (r < 0)
                goto ERROR;
 
index eda64e423bc32a863451972a2ba6e4e11ea87e8c..6f4458d24c6bdab5f64c0752fe87d17005946605 100644 (file)
@@ -233,13 +233,16 @@ static int __pakfire_repo_path(struct pakfire_repo* repo,
        settings of this repository.
 */
 static int pakfire_repo_xfer_create(
-               struct pakfire_xfer** xfer, struct pakfire_repo* repo, const char* url) {
+               struct pakfire_xfer** xfer, struct pakfire_repo* repo, const char* url, ...) {
        struct pakfire_mirrorlist* mirrorlist = NULL;
        const char* baseurl = NULL;
+       va_list args;
        int r;
 
+       va_start(args, url);
+
        // Create a new transfer
-       r = pakfire_xfer_create(xfer, repo->ctx, "%s", url);
+       r = pakfire_xfer_create(xfer, repo->ctx, url, args);
        if (r < 0)
                goto ERROR;
 
@@ -268,6 +271,7 @@ ERROR:
                if (*xfer)
                        pakfire_xfer_unref(*xfer);
        }
+       va_end(args);
 
        return r;
 }
@@ -435,7 +439,6 @@ static int pakfire_repo_download_database(struct pakfire_repo* repo,
                const char* filename, const char* path) {
        struct pakfire_xfer* xfer = NULL;
        char title[NAME_MAX];
-       char url[PATH_MAX];
        int r;
 
        // Do nothing if the file already exists
@@ -451,13 +454,8 @@ static int pakfire_repo_download_database(struct pakfire_repo* repo,
        if (r)
                return r;
 
-       // Make download URL
-       r = pakfire_string_format(url, "repodata/%s", filename);
-       if (r)
-               return r;
-
        // Create a new transfer
-       r = pakfire_repo_xfer_create(&xfer, repo, url);
+       r = pakfire_repo_xfer_create(&xfer, repo, "repodata/%s", filename);
        if (r)
                goto ERROR;
 
@@ -616,7 +614,7 @@ static int pakfire_repo_refresh_mirrorlist(struct pakfire_repo* repo, const int
        }
 
        // Create a new xfer
-       r = pakfire_repo_xfer_create(&xfer, repo, url);
+       r = pakfire_repo_xfer_create(&xfer, repo, "%s", url);
        if (r)
                goto ERROR;
 
@@ -1217,7 +1215,7 @@ int pakfire_repo_download_package(struct pakfire_repo* repo, struct pakfire_http
        }
 
        // Create a new transfer
-       r = pakfire_repo_xfer_create(&x, repo, url);
+       r = pakfire_repo_xfer_create(&x, repo, "%s", url);
        if (r)
                goto ERROR;
 
@@ -1274,7 +1272,7 @@ static int pakfire_repo_download(struct pakfire_repo* repo, const char* url,
        }
 
        // Create a new transfer
-       r = pakfire_repo_xfer_create(&xfer, repo, url);
+       r = pakfire_repo_xfer_create(&xfer, repo, "%s", url);
        if (r)
                goto ERROR;
 
index ff615fe91339ad899e3dc057695436c537b9f97c..7ede9220d345cc3edcc83430b4bf8b535c24b4ff 100644 (file)
@@ -341,18 +341,6 @@ ERROR:
 }
 
 int pakfire_xfer_create(struct pakfire_xfer** xfer,
-               struct pakfire_ctx* ctx, const char* url, ...) {
-       va_list args;
-       int r;
-
-       va_start(args, url);
-       r = __pakfire_xfer_create(xfer, ctx, url, args);
-       va_end(args);
-
-       return r;
-}
-
-int __pakfire_xfer_create(struct pakfire_xfer** xfer,
                struct pakfire_ctx* ctx, const char* url, va_list args) {
        struct pakfire_xfer* x = NULL;
        char buffer[PATH_MAX];