]> git.ipfire.org Git - pakfire.git/commitdiff
xfer: Fail creation when in offline mode
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 19:14:24 +0000 (19:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2024 19:14:24 +0000 (19:14 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/httpclient.c
src/libpakfire/xfer.c

index 128f1eb8e7ebc23502c76fdf83d248eee51667c5..15cc955d0ae2fd34e8898852206ff4e083083a2b 100644 (file)
@@ -395,12 +395,6 @@ int pakfire_httpclient_create(struct pakfire_httpclient** client,
        struct pakfire_httpclient* c = NULL;
        int r;
 
-       // Fail if the context is flagged as offline
-       if (pakfire_ctx_has_flag(ctx, PAKFIRE_CTX_OFFLINE)) {
-               CTX_ERROR(ctx, "Cannot initialize downloader in offline mode\n");
-               return -EPERM;
-       }
-
        // Allocate a new object
        c = calloc(1, sizeof(*c));
        if (!c)
index 7ede9220d345cc3edcc83430b4bf8b535c24b4ff..4f4b0c93229d55fda1d13308eac28d3f25e1b162 100644 (file)
@@ -346,6 +346,12 @@ int pakfire_xfer_create(struct pakfire_xfer** xfer,
        char buffer[PATH_MAX];
        int r;
 
+       // Fail if the context is flagged as offline
+       if (pakfire_ctx_has_flag(ctx, PAKFIRE_CTX_OFFLINE)) {
+               CTX_ERROR(ctx, "Cannot initialize a transfer in offline mode\n");
+               return -EPERM;
+       }
+
        // Format the URL
        r = __pakfire_string_vformat(buffer, sizeof(buffer), url, args);
        if (r < 0)