Skip to content

Commit

Permalink
WIP lib/repo-pull: Retry pulls without static deltas if they fail
Browse files Browse the repository at this point in the history
If pulling a static delta fails (due to one part of it missing from a
mirror, for example), retry the entire pull operation with
disable-static-deltas=true.

WIP: This needs some work to tidy it up.

Signed-off-by: Philip Withnall <[email protected]>

https://phabricator.endlessm.com/T22873
  • Loading branch information
pwithnall committed Jun 5, 2018
1 parent 8fbf19c commit fb67e9a
Showing 1 changed file with 43 additions and 7 deletions.
50 changes: 43 additions & 7 deletions src/libostree/ostree-repo-pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -3481,13 +3481,13 @@ initiate_request (OtPullData *pull_data,
* a transient network error, such as a socket timeout; default is 5, 0
* means return errors without retrying
*/
gboolean
ostree_repo_pull_with_options (OstreeRepo *self,
const char *remote_name_or_baseurl,
GVariant *options,
OstreeAsyncProgress *progress,
GCancellable *cancellable,
GError **error)
static gboolean
ostree_repo_pull_with_options_internal (OstreeRepo *self,
const char *remote_name_or_baseurl,
GVariant *options,
OstreeAsyncProgress *progress,
GCancellable *cancellable,
GError **error)
{
gboolean ret = FALSE;
g_autoptr(GBytes) bytes_summary = NULL;
Expand Down Expand Up @@ -4605,6 +4605,42 @@ ostree_repo_pull_with_options (OstreeRepo *self,
return ret;
}

gboolean
ostree_repo_pull_with_options (OstreeRepo *self,
const char *remote_name_or_baseurl,
GVariant *options,
OstreeAsyncProgress *progress,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GError) local_error = NULL;

if (!ostree_repo_pull_with_options_internal (self, remote_name_or_baseurl,
options, progress, cancellable,
&local_error))
{
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
(options == NULL ||
g_variant_lookup_value (options, "disable-static-deltas", NULL) == NULL))
{
g_autoptr(GVariant) modified_options = NULL;
g_auto(GVariantDict) modified_options_dict = G_VARIANT_DICT_INIT (options);
g_variant_dict_insert (&modified_options_dict, "disable-static-deltas",
"b", TRUE);
modified_options = g_variant_dict_end (&modified_options_dict);

return ostree_repo_pull_with_options_internal (self, remote_name_or_baseurl,
modified_options, progress,
cancellable, error);
}

g_propagate_error (error, g_steal_pointer (&local_error));
return FALSE;
}

return TRUE;
}

/* Structure used in ostree_repo_find_remotes_async() which stores metadata
* about a given OSTree commit. This includes the metadata from the commit
* #GVariant, plus some working state which is used to work out which remotes
Expand Down

0 comments on commit fb67e9a

Please sign in to comment.