[gnome-builder] runtime-manager: recover from NOT_SUPPORTED errors
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] runtime-manager: recover from NOT_SUPPORTED errors
- Date: Thu, 16 Feb 2017 22:19:13 +0000 (UTC)
commit bdd4f686273cafbcc99b8fe521f349a074a6abe3
Author: Christian Hergert <chergert redhat com>
Date: Thu Feb 16 14:18:43 2017 -0800
runtime-manager: recover from NOT_SUPPORTED errors
If the runtime provider does not support installing runtimes, then just
go ahead and synthesize a proper result if the runtime is available.
This fixes our issue where we need to try to install the runtime always
in case that it needs additional components.
libide/runtimes/ide-runtime-manager.c | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/libide/runtimes/ide-runtime-manager.c b/libide/runtimes/ide-runtime-manager.c
index d925f20..f06bff9 100644
--- a/libide/runtimes/ide-runtime-manager.c
+++ b/libide/runtimes/ide-runtime-manager.c
@@ -404,8 +404,28 @@ ide_runtime_manager_ensure_finish (IdeRuntimeManager *self,
GAsyncResult *result,
GError **error)
{
+ g_autoptr(GError) local_error = NULL;
+ IdeRuntime *ret;
+
g_return_val_if_fail (IDE_IS_RUNTIME_MANAGER (self), NULL);
g_return_val_if_fail (G_IS_TASK (result), NULL);
- return g_task_propagate_pointer (G_TASK (result), error);
+ ret = g_task_propagate_pointer (G_TASK (result), &local_error);
+
+ /*
+ * If we got NOT_SUPPORTED error, and the runtime already exists,
+ * then we can synthesize a successful result to the caller.
+ */
+ if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
+ {
+ const gchar *runtime_id = g_task_get_task_data (G_TASK (result));
+ ret = ide_runtime_manager_get_runtime (self, runtime_id);
+ if (ret != NULL)
+ return ret;
+ }
+
+ if (error != NULL)
+ *error = g_steal_pointer (&local_error);
+
+ return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]