repo: merge repo_remote_fetch_summary_{metalink,url}
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
133fb5ffdc
commit
783e83c62c
|
|
@ -1671,170 +1671,104 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
repo_remote_fetch_summary_url (OstreeRepo *self,
|
repo_remote_fetch_summary (OstreeRepo *self,
|
||||||
const char *name,
|
const char *name,
|
||||||
GBytes **out_summary,
|
const char *metalink_url_string,
|
||||||
GBytes **out_signatures,
|
GBytes **out_summary,
|
||||||
GCancellable *cancellable,
|
GBytes **out_signatures,
|
||||||
GError **error)
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
glnx_unref_object OstreeFetcher *fetcher = NULL;
|
glnx_unref_object OstreeFetcher *fetcher = NULL;
|
||||||
g_autoptr(GMainLoop) main_loop = NULL;
|
g_autoptr(GMainLoop) main_loop = NULL;
|
||||||
g_autofree char *url_string = NULL;
|
gboolean ret = FALSE;
|
||||||
SoupURI *base_uri = NULL;
|
SoupURI *base_uri = NULL;
|
||||||
gboolean ret = FALSE;
|
uint i;
|
||||||
|
|
||||||
if (!ostree_repo_remote_get_url (self, name, &url_string, error))
|
const char *filenames[] = {"summary", "summary.sig"};
|
||||||
goto out;
|
GBytes **outputs[] = {out_summary, out_signatures};
|
||||||
|
|
||||||
base_uri = soup_uri_new (url_string);
|
|
||||||
|
|
||||||
if (base_uri == NULL)
|
|
||||||
{
|
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
||||||
"Invalid URL '%s'", url_string);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
fetcher = _ostree_repo_remote_new_fetcher (self, name, error);
|
|
||||||
|
|
||||||
if (fetcher == NULL)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
main_loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
|
main_loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
|
||||||
|
|
||||||
{
|
|
||||||
SoupURI *uri;
|
|
||||||
const char *base_path;
|
|
||||||
g_autofree char *path = NULL;
|
|
||||||
|
|
||||||
base_path = soup_uri_get_path (base_uri);
|
|
||||||
path = g_build_filename (base_path, "summary", NULL);
|
|
||||||
uri = soup_uri_new_with_base (base_uri, path);
|
|
||||||
|
|
||||||
ret = _ostree_fetcher_request_uri_to_membuf (fetcher, uri,
|
|
||||||
FALSE, TRUE,
|
|
||||||
out_summary,
|
|
||||||
main_loop,
|
|
||||||
OSTREE_MAX_METADATA_SIZE,
|
|
||||||
cancellable, error);
|
|
||||||
soup_uri_free (uri);
|
|
||||||
|
|
||||||
if (!ret)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
SoupURI *uri;
|
|
||||||
const char *base_path;
|
|
||||||
g_autofree char *path = NULL;
|
|
||||||
|
|
||||||
base_path = soup_uri_get_path (base_uri);
|
|
||||||
path = g_build_filename (base_path, "summary.sig", NULL);
|
|
||||||
uri = soup_uri_new_with_base (base_uri, path);
|
|
||||||
|
|
||||||
ret = _ostree_fetcher_request_uri_to_membuf (fetcher, uri,
|
|
||||||
FALSE, TRUE,
|
|
||||||
out_signatures,
|
|
||||||
main_loop,
|
|
||||||
OSTREE_MAX_METADATA_SIZE,
|
|
||||||
cancellable, error);
|
|
||||||
soup_uri_free (uri);
|
|
||||||
|
|
||||||
if (!ret)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
|
||||||
if (base_uri != NULL)
|
|
||||||
soup_uri_free (base_uri);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
repo_remote_fetch_summary_metalink (OstreeRepo *self,
|
|
||||||
const char *name,
|
|
||||||
const char *metalink_url_string,
|
|
||||||
GBytes **out_summary,
|
|
||||||
GBytes **out_signatures,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
glnx_unref_object OstreeFetcher *fetcher = NULL;
|
|
||||||
g_autoptr(GMainLoop) main_loop = NULL;
|
|
||||||
SoupURI *metalink_uri = NULL;
|
|
||||||
gboolean ret = FALSE;
|
|
||||||
|
|
||||||
metalink_uri = soup_uri_new (metalink_url_string);
|
|
||||||
|
|
||||||
if (metalink_uri == NULL)
|
|
||||||
{
|
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
||||||
"Invalid URL '%s'", metalink_url_string);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
fetcher = _ostree_repo_remote_new_fetcher (self, name, error);
|
fetcher = _ostree_repo_remote_new_fetcher (self, name, error);
|
||||||
|
|
||||||
if (fetcher == NULL)
|
if (fetcher == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
main_loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
|
base_uri = soup_uri_new (metalink_url_string);
|
||||||
|
|
||||||
{
|
{
|
||||||
glnx_unref_object OstreeMetalink *metalink = NULL;
|
g_autofree char *url_string = NULL;
|
||||||
GError *local_error = NULL;
|
if (metalink_url_string)
|
||||||
|
url_string = g_strdup (metalink_url_string);
|
||||||
metalink = _ostree_metalink_new (fetcher, "summary",
|
else
|
||||||
OSTREE_MAX_METADATA_SIZE,
|
|
||||||
metalink_uri);
|
|
||||||
|
|
||||||
_ostree_metalink_request_sync (metalink, main_loop,
|
|
||||||
NULL, out_summary, NULL,
|
|
||||||
cancellable, &local_error);
|
|
||||||
|
|
||||||
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
|
||||||
{
|
{
|
||||||
g_clear_error (&local_error);
|
if (!ostree_repo_remote_get_url (self, name, &url_string, error))
|
||||||
*out_summary = NULL;
|
goto out;
|
||||||
}
|
}
|
||||||
else if (local_error != NULL)
|
|
||||||
|
base_uri = soup_uri_new (url_string);
|
||||||
|
if (base_uri == NULL)
|
||||||
{
|
{
|
||||||
g_propagate_error (error, local_error);
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"Invalid URL '%s'", url_string);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
for (i = 0; i < G_N_ELEMENTS (filenames); i++)
|
||||||
glnx_unref_object OstreeMetalink *metalink = NULL;
|
{
|
||||||
GError *local_error = NULL;
|
if (metalink_url_string)
|
||||||
|
{
|
||||||
|
glnx_unref_object OstreeMetalink *metalink = NULL;
|
||||||
|
GError *local_error = NULL;
|
||||||
|
|
||||||
metalink = _ostree_metalink_new (fetcher, "summary.sig",
|
metalink = _ostree_metalink_new (fetcher, filenames[i],
|
||||||
OSTREE_MAX_METADATA_SIZE,
|
OSTREE_MAX_METADATA_SIZE,
|
||||||
metalink_uri);
|
base_uri);
|
||||||
|
|
||||||
_ostree_metalink_request_sync (metalink, main_loop,
|
_ostree_metalink_request_sync (metalink, main_loop,
|
||||||
NULL, out_signatures, NULL,
|
NULL, outputs[i], NULL,
|
||||||
cancellable, &local_error);
|
cancellable, &local_error);
|
||||||
|
|
||||||
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
||||||
{
|
{
|
||||||
g_clear_error (&local_error);
|
g_clear_error (&local_error);
|
||||||
*out_signatures = NULL;
|
*outputs[i] = NULL;
|
||||||
}
|
}
|
||||||
else if (local_error != NULL)
|
else if (local_error != NULL)
|
||||||
{
|
{
|
||||||
g_propagate_error (error, local_error);
|
g_propagate_error (error, local_error);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SoupURI *uri;
|
||||||
|
const char *base_path;
|
||||||
|
g_autofree char *path = NULL;
|
||||||
|
|
||||||
|
base_path = soup_uri_get_path (base_uri);
|
||||||
|
path = g_build_filename (base_path, filenames[i], NULL);
|
||||||
|
uri = soup_uri_new_with_base (base_uri, path);
|
||||||
|
|
||||||
|
ret = _ostree_fetcher_request_uri_to_membuf (fetcher, uri,
|
||||||
|
FALSE, TRUE,
|
||||||
|
outputs[i],
|
||||||
|
main_loop,
|
||||||
|
OSTREE_MAX_METADATA_SIZE,
|
||||||
|
cancellable, error);
|
||||||
|
soup_uri_free (uri);
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (metalink_uri != NULL)
|
if (base_uri != NULL)
|
||||||
soup_uri_free (metalink_uri);
|
soup_uri_free (base_uri);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -1883,25 +1817,14 @@ ostree_repo_remote_fetch_summary (OstreeRepo *self,
|
||||||
&metalink_url_string, error))
|
&metalink_url_string, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (metalink_url_string == NULL)
|
if (!repo_remote_fetch_summary (self,
|
||||||
{
|
name,
|
||||||
if (!repo_remote_fetch_summary_url (self, name,
|
metalink_url_string,
|
||||||
&summary,
|
&summary,
|
||||||
&signatures,
|
&signatures,
|
||||||
cancellable,
|
cancellable,
|
||||||
error))
|
error))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!repo_remote_fetch_summary_metalink (self, name,
|
|
||||||
metalink_url_string,
|
|
||||||
&summary,
|
|
||||||
&signatures,
|
|
||||||
cancellable,
|
|
||||||
error))
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ostree_repo_remote_get_gpg_verify_summary (self, name, &gpg_verify_summary, error))
|
if (!ostree_repo_remote_get_gpg_verify_summary (self, name, &gpg_verify_summary, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue