Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrero committed Sep 27, 2023
1 parent ac8e574 commit 5bbf1d7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 46 deletions.
35 changes: 0 additions & 35 deletions src/libostree/ostree-fetcher-curl.h

This file was deleted.

6 changes: 4 additions & 2 deletions src/libostree/ostree-fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ void _ostree_fetcher_set_proxy (OstreeFetcher *fetcher, const char *proxy);
void _ostree_fetcher_set_client_cert (OstreeFetcher *fetcher, const char *cert_path,
const char *key_path);

void _ostree_fetcher_set_low_speed_limit (OstreeFetcher *self, long int *opt_low_speed_limit);
void _ostree_fetcher_set_low_speed_limit (OstreeFetcher *self, long *opt_low_speed_limit);

void _ostree_fetcher_set_low_speed_time (OstreeFetcher *self, long int *opt_low_speed_time);
void _ostree_fetcher_set_low_speed_time (OstreeFetcher *self, long *opt_low_speed_time);

void _ostree_fetcher_set_retry_all (OstreeFetcher *self, gboolean *opt_retry_all;

void _ostree_fetcher_set_tls_database (OstreeFetcher *self, const char *tlsdb_path);

Expand Down
5 changes: 3 additions & 2 deletions src/libostree/ostree-repo-pull-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ typedef struct

GVariant *extra_headers;
char *append_user_agent;
long int *low_speed_limit;
long int *low_speed_time;
long low_speed_limit;
long low_speed_time;
gboolean retry_all;


gboolean dry_run;
Expand Down
23 changes: 16 additions & 7 deletions src/libostree/ostree-repo-pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#define DEFAULT_N_NETWORK_RETRIES 5
#define OPT_LOWSPEEDLIMIT_DEFAULT 1000L
#define OPT_LOWSPEEDTIME_DEFAULT 30L
#define OPT_RETRYALL_DEFAULT true

typedef struct
{
Expand Down Expand Up @@ -2930,8 +2931,9 @@ _ostree_repo_cache_summary (OstreeRepo *self, const char *remote, GBytes *summar
static OstreeFetcher *
_ostree_repo_remote_new_fetcher (OstreeRepo *self, const char *remote_name, gboolean gzip,
GVariant *extra_headers, const char *append_user_agent,
long int *low_speed_limit, long int *low_speed_time,
OstreeFetcherSecurityState *out_state, GError **error)
long low_speed_limit, long low_speed_time,
gboolean retry_all, OstreeFetcherSecurityState *out_state,
GError **error)
{
OstreeFetcher *fetcher = NULL;
OstreeFetcherConfigFlags fetcher_flags = 0;
Expand Down Expand Up @@ -3000,6 +3002,7 @@ _ostree_repo_remote_new_fetcher (OstreeRepo *self, const char *remote_name, gboo

_ostree_fetcher_set_low_speed_limit (fetcher, (low_speed_limit) ? low_speed_limit : OPT_LOWSPEEDLIMIT_DEFAULT);
_ostree_fetcher_set_low_speed_time (fetcher, (low_speed_time) ? low_speed_time : OPT_LOWSPEEDTIME_DEFAULT);
_ostree_fetcher_set_retry_all (fetcher, (retry_all) ? retry_all : OPT_RETRYALL_DEFAULT);

{
g_autofree char *tls_ca_path = NULL;
Expand Down Expand Up @@ -3227,7 +3230,7 @@ reinitialize_fetcher (OtPullData *pull_data, const char *remote_name, GError **e
g_clear_object (&pull_data->fetcher);
pull_data->fetcher = _ostree_repo_remote_new_fetcher (
pull_data->repo, remote_name, FALSE, pull_data->extra_headers, pull_data->append_user_agent,
pull_data->low_speed_limit, pull_data->low_speed_time,
pull_data->low_speed_limit, pull_data->low_speed_time, pull_data->retry_all,
&pull_data->fetcher_security_state, error);
if (pull_data->fetcher == NULL)
return FALSE;
Expand Down Expand Up @@ -3461,6 +3464,8 @@ all_requested_refs_have_commit (
during the time set via "low-speed-time-seconds" for libcurl to abort.
* * `low-speed-time-seconds` (`u`): The time in number seconds that the transfer
speed should be below the "low-speed-limit-bytes" setting for libcurl to abort.
* * `retry-all-network-errors` (`b`): Retry when network issues happen, instead of
* failing automatically. Currently only affects libcurl. (Default set to true)
* * `ref-keyring-map` (`a(sss)`): Array of (collection ID, ref name, keyring
* remote name) tuples specifying which remote's keyring should be used when
* doing GPG verification of each collection-ref. This is useful to prevent a
Expand Down Expand Up @@ -3583,6 +3588,7 @@ ostree_repo_pull_with_options (OstreeRepo *self, const char *remote_name_or_base
(void)g_variant_lookup (options, "append-user-agent", "s", &pull_data->append_user_agent);
(void)g_variant_lookup (options, "low-speed-limit-bytes", "u", &pull_data->low_speed_limit);
(void)g_variant_lookup (options, "low-speed-time-seconds", "u", &pull_data->low_speed_time);
(void)g_variant_lookup (options, "retry-all-network-errors", "b", &pull_data->retry_all);
opt_n_network_retries_set
= g_variant_lookup (options, "n-network-retries", "u", &pull_data->n_network_retries);
opt_ref_keyring_map_set
Expand Down Expand Up @@ -4910,6 +4916,7 @@ ostree_repo_pull_with_options (OstreeRepo *self, const char *remote_name_or_base
g_free (pull_data->append_user_agent);
g_free (pull_data->low_speed_limit);
g_free (pull_data->low_speed_time);
g_free (pull_data->retry_all);
g_clear_pointer (&pull_data->signapi_commit_verifiers, g_ptr_array_unref);
g_clear_pointer (&pull_data->signapi_summary_verifiers, g_ptr_array_unref);
g_clear_pointer (&pull_data->meta_mirrorlist, g_ptr_array_unref);
Expand Down Expand Up @@ -5708,7 +5715,7 @@ find_remotes_cb (GObject *obj, GAsyncResult *async_result, gpointer user_data)
goto error;

fetcher = _ostree_repo_remote_new_fetcher (self, result->remote->name, TRUE, NULL,
NULL, NULL, NULL, NULL, &error);
NULL, NULL, NULL, TRUE, NULL, &error);
if (fetcher == NULL)
goto error;

Expand Down Expand Up @@ -6322,8 +6329,9 @@ ostree_repo_remote_fetch_summary_with_options (OstreeRepo *self, const char *nam
g_autoptr (GVariant) extra_headers = NULL;
g_autoptr (GPtrArray) mirrorlist = NULL;
const char *append_user_agent = NULL;
long int *low_speed_limit = NULL;
long int *low_speed_time = NULL;
long low_speed_limit = OPT_LOWSPEEDLIMIT_DEFAULT;
long low_speed_time = OPT_LOWSPEEDTIME_DEFAULT;
gboolean retry_all = OPT_RETRYALL_DEFAULT;
guint n_network_retries = DEFAULT_N_NETWORK_RETRIES;
gboolean summary_sig_not_modified = FALSE;
g_autofree char *summary_sig_if_none_match = NULL;
Expand All @@ -6350,6 +6358,7 @@ ostree_repo_remote_fetch_summary_with_options (OstreeRepo *self, const char *nam
(void)g_variant_lookup (options, "n-network-retries", "u", &n_network_retries);
(void)g_variant_lookup (options, "low-speed-limit-bytes", "u", &low_speed_limit);
(void)g_variant_lookup (options, "low-speed-time-seconds", "u", &low_speed_time);
(void)g_variant_lookup (options, "retry-all-network-errors", "b", &retry_all);
}

if (!ostree_repo_remote_get_gpg_verify_summary (self, name, &gpg_verify_summary, error))
Expand All @@ -6362,7 +6371,7 @@ ostree_repo_remote_fetch_summary_with_options (OstreeRepo *self, const char *nam
(void)mainctx; // Used for autocleanup

fetcher = _ostree_repo_remote_new_fetcher (self, name, TRUE, extra_headers, append_user_agent,
low_speed_limit, low_speed_time, NULL, error);
low_speed_limit, low_speed_time, retry_all, NULL, error);
if (fetcher == NULL)
return FALSE;

Expand Down

0 comments on commit 5bbf1d7

Please sign in to comment.