|
|
4c949f |
From 5d327081b489bd58e5fbafc5cff9c893b46e996c Mon Sep 17 00:00:00 2001
|
|
|
4c949f |
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
|
|
|
4c949f |
Date: Mon, 25 Mar 2019 11:44:29 +0100
|
|
|
4c949f |
Subject: [PATCH] tree: Also check fore "treeinfo" in addition to ".treeinfo"
|
|
|
4c949f |
MIME-Version: 1.0
|
|
|
4c949f |
Content-Type: text/plain; charset=UTF-8
|
|
|
4c949f |
Content-Transfer-Encoding: 8bit
|
|
|
4c949f |
|
|
|
4c949f |
Akamai CDN hosted files can't start with a dot, making trees published to
|
|
|
4c949f |
a CDN having their ".treeinfo" files renamed to "treeinfo".
|
|
|
4c949f |
|
|
|
4c949f |
https://gitlab.com/libosinfo/libosinfo/issues/18
|
|
|
4c949f |
|
|
|
4c949f |
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
|
|
|
4c949f |
Reviewed-by: Cole Robinson <crobinso@redhat.com>
|
|
|
4c949f |
(cherry picked from commit e8e0ca9024847aca9d079ffb34a2bbd0494fe978)
|
|
|
4c949f |
---
|
|
|
4c949f |
osinfo/osinfo_tree.c | 67 +++++++++++++++++++++++++++++++++-----------
|
|
|
4c949f |
1 file changed, 50 insertions(+), 17 deletions(-)
|
|
|
4c949f |
|
|
|
4c949f |
diff --git a/osinfo/osinfo_tree.c b/osinfo/osinfo_tree.c
|
|
|
4c949f |
index ef82807..eaac54f 100644
|
|
|
4c949f |
--- a/osinfo/osinfo_tree.c
|
|
|
4c949f |
+++ b/osinfo/osinfo_tree.c
|
|
|
4c949f |
@@ -35,6 +35,7 @@ typedef struct _CreateFromLocationAsyncData CreateFromLocationAsyncData;
|
|
|
4c949f |
struct _CreateFromLocationAsyncData {
|
|
|
4c949f |
GFile *file;
|
|
|
4c949f |
gchar *location;
|
|
|
4c949f |
+ gchar *treeinfo;
|
|
|
4c949f |
|
|
|
4c949f |
GTask *res;
|
|
|
4c949f |
|
|
|
4c949f |
@@ -594,6 +595,11 @@ static OsinfoTree *load_keyinfo(const gchar *location,
|
|
|
4c949f |
return tree;
|
|
|
4c949f |
}
|
|
|
4c949f |
|
|
|
4c949f |
+static void
|
|
|
4c949f |
+osinfo_tree_create_from_location_async_helper(const gchar *url,
|
|
|
4c949f |
+ const gchar *treeinfo,
|
|
|
4c949f |
+ GCancellable *cancellable,
|
|
|
4c949f |
+ CreateFromLocationAsyncData *data);
|
|
|
4c949f |
|
|
|
4c949f |
static void on_location_read(GObject *source,
|
|
|
4c949f |
GAsyncResult *res,
|
|
|
4c949f |
@@ -613,7 +619,17 @@ static void on_location_read(GObject *source,
|
|
|
4c949f |
&length,
|
|
|
4c949f |
NULL,
|
|
|
4c949f |
&error)) {
|
|
|
4c949f |
- g_prefix_error(&error, _("Failed to load .treeinfo file: "));
|
|
|
4c949f |
+ /* It means no ".treeinfo" file has been found. Try again, this time
|
|
|
4c949f |
+ * looking for a "treeinfo" file. */
|
|
|
4c949f |
+ if (g_str_equal(data->treeinfo, ".treeinfo")) {
|
|
|
4c949f |
+ osinfo_tree_create_from_location_async_helper(data->location,
|
|
|
4c949f |
+ "treeinfo",
|
|
|
4c949f |
+ g_task_get_cancellable(data->res),
|
|
|
4c949f |
+ data);
|
|
|
4c949f |
+ return;
|
|
|
4c949f |
+ }
|
|
|
4c949f |
+
|
|
|
4c949f |
+ g_prefix_error(&error, _("Failed to load .treeinfo|treeinfo file: "));
|
|
|
4c949f |
g_task_return_error(data->res, error);
|
|
|
4c949f |
create_from_location_async_data_free(data);
|
|
|
4c949f |
return;
|
|
|
4c949f |
@@ -635,6 +651,35 @@ static void on_location_read(GObject *source,
|
|
|
4c949f |
g_free(content);
|
|
|
4c949f |
}
|
|
|
4c949f |
|
|
|
4c949f |
+static void
|
|
|
4c949f |
+osinfo_tree_create_from_location_async_helper(const gchar *url,
|
|
|
4c949f |
+ const gchar *treeinfo,
|
|
|
4c949f |
+ GCancellable *cancellable,
|
|
|
4c949f |
+ CreateFromLocationAsyncData *data)
|
|
|
4c949f |
+{
|
|
|
4c949f |
+ gchar *location;
|
|
|
4c949f |
+
|
|
|
4c949f |
+ g_return_if_fail(url != NULL);
|
|
|
4c949f |
+ g_return_if_fail(treeinfo != NULL);
|
|
|
4c949f |
+
|
|
|
4c949f |
+ location = g_strdup_printf("%s/%s", url, treeinfo);
|
|
|
4c949f |
+
|
|
|
4c949f |
+ g_clear_object(&data->file);
|
|
|
4c949f |
+ data->file = g_file_new_for_uri(location);
|
|
|
4c949f |
+
|
|
|
4c949f |
+ g_free(data->location);
|
|
|
4c949f |
+ data->location = g_strdup(url);
|
|
|
4c949f |
+
|
|
|
4c949f |
+ g_free(data->treeinfo);
|
|
|
4c949f |
+ data->treeinfo = g_strdup(treeinfo);
|
|
|
4c949f |
+
|
|
|
4c949f |
+ g_file_load_contents_async(data->file,
|
|
|
4c949f |
+ cancellable,
|
|
|
4c949f |
+ on_location_read,
|
|
|
4c949f |
+ data);
|
|
|
4c949f |
+ g_free(location);
|
|
|
4c949f |
+}
|
|
|
4c949f |
+
|
|
|
4c949f |
/**
|
|
|
4c949f |
* osinfo_tree_create_from_location_async:
|
|
|
4c949f |
* @location: the location of an installation tree
|
|
|
4c949f |
@@ -652,11 +697,6 @@ void osinfo_tree_create_from_location_async(const gchar *location,
|
|
|
4c949f |
gpointer user_data)
|
|
|
4c949f |
{
|
|
|
4c949f |
CreateFromLocationAsyncData *data;
|
|
|
4c949f |
- gchar *treeinfo;
|
|
|
4c949f |
-
|
|
|
4c949f |
- g_return_if_fail(location != NULL);
|
|
|
4c949f |
-
|
|
|
4c949f |
- treeinfo = g_strdup_printf("%s/.treeinfo", location);
|
|
|
4c949f |
|
|
|
4c949f |
data = g_slice_new0(CreateFromLocationAsyncData);
|
|
|
4c949f |
data->res = g_task_new(NULL,
|
|
|
4c949f |
@@ -665,17 +705,10 @@ void osinfo_tree_create_from_location_async(const gchar *location,
|
|
|
4c949f |
user_data);
|
|
|
4c949f |
g_task_set_priority(data->res, priority);
|
|
|
4c949f |
|
|
|
4c949f |
- data->file = g_file_new_for_uri(treeinfo);
|
|
|
4c949f |
- data->location = g_strdup(location);
|
|
|
4c949f |
-
|
|
|
4c949f |
- /* XXX priority ? */
|
|
|
4c949f |
- /* XXX probe other things besides just tree info */
|
|
|
4c949f |
- g_file_load_contents_async(data->file,
|
|
|
4c949f |
- cancellable,
|
|
|
4c949f |
- on_location_read,
|
|
|
4c949f |
- data);
|
|
|
4c949f |
-
|
|
|
4c949f |
- g_free(treeinfo);
|
|
|
4c949f |
+ osinfo_tree_create_from_location_async_helper(location,
|
|
|
4c949f |
+ ".treeinfo",
|
|
|
4c949f |
+ cancellable,
|
|
|
4c949f |
+ data);
|
|
|
4c949f |
}
|
|
|
4c949f |
|
|
|
4c949f |
|
|
|
4c949f |
--
|
|
|
4c949f |
2.21.0
|
|
|
4c949f |
|