#include <pakfire/client.h>
#include <pakfire/util.h>
+#include "api.h"
#include "command.h"
#include "pakfire.h"
#include "upload_delete.h"
return 0;
}
+static int delete_callback(pakfire_xfer* xfer,
+ const pakfire_xfer_response* response, void* data) {
+ const char* uuid = data;
+ int r;
+
+ // Handle errors
+ r = cli_api_error(response, "Failed to delete the upload");
+ if (r < 0)
+ return 0;
+
+ // Show result
+ printf("Upload %s has been successfully deleted\n", uuid);
+
+ return 0;
+}
+
static int ready_callback(pakfire_client* client, void* data) {
const struct cli_local_args* local_args = data;
int r;
// Delete all uploads
for (unsigned int i = 0; i < local_args->num_uploads; i++) {
- r = pakfire_client_delete_upload(client, local_args->uploads[i]);
+ r = pakfire_client_delete_upload(client,
+ local_args->uploads[i], delete_callback, (char*)local_args->uploads[i]);
if (r < 0)
return r;
}
return r;
}
-int pakfire_client_delete_upload(pakfire_client* self, const char* uuid) {
+int pakfire_client_delete_upload(pakfire_client* self, const char* uuid,
+ pakfire_xfer_response_callback callback, void* data) {
pakfire_xfer* xfer = NULL;
int r;
if (r < 0)
goto ERROR;
+ // Register the callback
+ r = pakfire_xfer_set_response_callback(xfer, callback, data);
+ if (r < 0)
+ goto ERROR;
+
// Enqueue the transfer
r = pakfire_httpclient_enqueue(self->httpclient, xfer);
if (r < 0)
typedef pakfire_xfer_response_callback pakfire_client_list_uploads_callback;
int pakfire_client_list_uploads(pakfire_client* client,
- pakfire_client_list_uploads_callback callback, void* data);
-int pakfire_client_delete_upload(pakfire_client* client, const char* uuid);
+ pakfire_client_list_uploads_callback callback, void* data);
+int pakfire_client_delete_upload(pakfire_client* self, const char* uuid,
+ pakfire_xfer_response_callback callback, void* data);
// Repositories