Skip to content

Commit

Permalink
pkcon: Use appropriate finish call for each async call
Browse files Browse the repository at this point in the history
  • Loading branch information
sidt4 committed May 10, 2024
1 parent 06b0675 commit d51546d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion client/pk-console.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ typedef struct {
PkProgressBar *progressbar;
PkTaskText *task;
gboolean is_console;
gboolean is_client;
gint retval;
PkBitfield filters;
guint defered_status_id;
Expand Down Expand Up @@ -660,7 +661,11 @@ pk_console_finished_cb (GObject *object, GAsyncResult *res, gpointer data)
}

/* get the results */
results = pk_task_generic_finish (PK_TASK (ctx->task), res, &error);
if (ctx->is_client)
results = pk_client_generic_finish (PK_CLIENT (ctx->task), res, &error);
else
results = pk_task_generic_finish (PK_TASK (ctx->task), res, &error);

if (results == NULL) {
/* TRANSLATORS: we failed to get any results, which is pretty
* fatal in my book */
Expand Down Expand Up @@ -1271,6 +1276,7 @@ pk_console_get_details (PkConsoleCtx *ctx, gchar **packages, GError **error)

/* local file */
if (g_file_test (packages[0], G_FILE_TEST_EXISTS)) {
ctx->is_client = TRUE;
pk_client_get_details_local_async (PK_CLIENT (ctx->task),
packages,
ctx->cancellable,
Expand Down Expand Up @@ -1303,6 +1309,7 @@ pk_console_get_details (PkConsoleCtx *ctx, gchar **packages, GError **error)
static gboolean
pk_console_get_details_local (PkConsoleCtx *ctx, gchar **files, GError **error)
{
ctx->is_client = TRUE;
pk_client_get_details_local_async (PK_CLIENT (ctx->task),
files,
ctx->cancellable,
Expand All @@ -1314,6 +1321,7 @@ pk_console_get_details_local (PkConsoleCtx *ctx, gchar **files, GError **error)
static gboolean
pk_console_get_files_local (PkConsoleCtx *ctx, gchar **files, GError **error)
{
ctx->is_client = TRUE;
pk_client_get_files_local_async (PK_CLIENT (ctx->task),
files,
ctx->cancellable,
Expand All @@ -1330,6 +1338,7 @@ pk_console_get_files (PkConsoleCtx *ctx, gchar **packages, GError **error)

/* local file */
if (g_file_test (packages[0], G_FILE_TEST_EXISTS)) {
ctx->is_client = TRUE;
pk_client_get_files_local_async (PK_CLIENT (ctx->task),
packages,
ctx->cancellable,
Expand Down Expand Up @@ -1932,6 +1941,7 @@ main (int argc, char *argv[])
ctx->retval = PK_EXIT_CODE_SYNTAX_INVALID;
goto out;
}
ctx->is_client = TRUE;
pk_client_install_signature_async (PK_CLIENT (ctx->task),
PK_SIGTYPE_ENUM_GPG,
details,
Expand Down Expand Up @@ -1988,6 +1998,7 @@ main (int argc, char *argv[])
ctx->retval = PK_EXIT_CODE_SYNTAX_INVALID;
goto out;
}
ctx->is_client = TRUE;
pk_client_accept_eula_async (PK_CLIENT (ctx->task),
value,
ctx->cancellable,
Expand Down Expand Up @@ -2064,6 +2075,7 @@ main (int argc, char *argv[])
ctx->retval = PK_EXIT_CODE_SYNTAX_INVALID;
goto out;
}
ctx->is_client = TRUE;
pk_client_repo_set_data_async (PK_CLIENT (ctx->task),
value,
details,
Expand All @@ -2081,6 +2093,7 @@ main (int argc, char *argv[])
ctx->retval = PK_EXIT_CODE_SYNTAX_INVALID;
goto out;
}
ctx->is_client = TRUE;
pk_client_repo_remove_async (PK_CLIENT (ctx->task),
pk_bitfield_from_enums (PK_TRANSACTION_FLAG_ENUM_SIMULATE,
-1),
Expand Down Expand Up @@ -2141,6 +2154,7 @@ main (int argc, char *argv[])
run_mainloop = pk_console_depends_on (ctx, argv + 2, &error);

} else if (strcmp (mode, "get-distro-upgrades") == 0) {
ctx->is_client = TRUE;
pk_client_get_distro_upgrades_async (PK_CLIENT (ctx->task),
ctx->cancellable,
pk_console_progress_cb, ctx,
Expand Down Expand Up @@ -2337,6 +2351,7 @@ main (int argc, char *argv[])
ctx->retval = error->code;

} else if (strcmp (mode, "get-transactions") == 0) {
ctx->is_client = TRUE;
pk_client_get_old_transactions_async (PK_CLIENT (ctx->task),
10,
ctx->cancellable,
Expand Down

0 comments on commit d51546d

Please sign in to comment.