]> git.ipfire.org Git - pakfire.git/commitdiff
xfer: Remove convenience function to run synchronous API requests
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Jun 2025 08:40:39 +0000 (08:40 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Jun 2025 08:40:39 +0000 (08:40 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/xfer.c
src/pakfire/xfer.h

index 9419062f81a349bae4cc3766ef025b1362d3cf0e..1b4136e25dc1e0a3a2587218aff0321fcf7f029c 100644 (file)
@@ -1920,70 +1920,3 @@ ERROR:
 
        return r;
 }
-
-static pakfire_xfer_error_code_t pakfire_xfer_run_api_request_once(
-               struct pakfire_xfer* xfer, struct json_object** response) {
-       char* buffer = NULL;
-       size_t length = 0;
-       int r;
-
-       // Write the response to the buffer
-       r = pakfire_xfer_set_output_buffer(xfer, &buffer, &length);
-       if (r)
-               goto ERROR;
-
-       // Run the xfer
-       r = pakfire_xfer_run(xfer, PAKFIRE_XFER_NO_PROGRESS);
-       if (r)
-               goto ERROR;
-
-       // Parse the response
-       r = pakfire_xfer_parse_api_response(xfer, buffer, length, response);
-       if (r) {
-               ERROR(xfer->ctx, "Could not parse the API response: %s\n", strerror(-r));
-               goto ERROR;
-       }
-
-ERROR:
-       // Reset the output stream
-       pakfire_xfer_reset_output(xfer);
-
-       if (buffer)
-               free(buffer);
-
-       return r;
-}
-
-/*
-       This function sends a request and automatically parses the response.
-       The response might optionally be returned if response is not NULL.
-*/
-pakfire_xfer_error_code_t pakfire_xfer_run_api_request(
-               struct pakfire_xfer* xfer, struct json_object* request, struct json_object** response) {
-       pakfire_xfer_error_code_t r;
-
-       // Set the request body
-       if (request) {
-               r = pakfire_xfer_set_json_payload(xfer, request);
-               if (r < 0)
-                       return r;
-       }
-
-       // Loop indefinitely...
-       for (;;) {
-               r = pakfire_xfer_run_api_request_once(xfer, response);
-               switch (r) {
-                       // Try again after five seconds for recoverable errors
-                       case PAKFIRE_XFER_DNS_ERROR:
-                       case PAKFIRE_XFER_TRANSPORT_ERROR:
-                       case PAKFIRE_XFER_TIMEOUT:
-                               usleep(5000000);
-                               break;
-
-                       default:
-                               return r;
-               }
-       }
-
-       return 0;
-}
index 06d3460df814bd17815496542aea7aef41ba591e..855b38bce2ab87c0eb63098dc961e036cd39f2a4 100644 (file)
@@ -140,8 +140,6 @@ int pakfire_xfer_prepare(struct pakfire_xfer* xfer, struct pakfire_progress* pro
 pakfire_xfer_error_code_t pakfire_xfer_done(struct pakfire_xfer* xfer, sd_event* loop, int code);
 
 pakfire_xfer_error_code_t pakfire_xfer_run(struct pakfire_xfer* xfer, int flags);
-pakfire_xfer_error_code_t pakfire_xfer_run_api_request(
-       struct pakfire_xfer* xfer, struct json_object* request, struct json_object** response);
 
 // WebSocket
 typedef int (*pakfire_xfer_open_callback)(struct pakfire_xfer* xfer, void* data);