Skip to content

Commit

Permalink
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.

This is a functional, but ugly approach to fixing the problem, and a
neater solution may be adopted upstream in future. If so, this commit
should be dropped and replaced with the upstream solution:

ostreedev/ostree#1612

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

https://phabricator.endlessm.com/T22873

Rebase 2018.6 (T23138): Fix a minor merge conflict due to "#ifdef
  OSTREE_ENABLE_EXPERIMENTAL_API" being gone now.
  • Loading branch information
pwithnall authored and mwleeds committed Jan 22, 2019
1 parent 4db8699 commit 0e04192
Showing 1 changed file with 51 additions and 7 deletions.
58 changes: 51 additions & 7 deletions src/libostree/ostree-repo-pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -3508,13 +3508,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 @@ -4681,6 +4681,50 @@ 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))
{
gboolean disable_static_deltas = FALSE, require_static_deltas = FALSE;

if (options != NULL)
{
g_variant_lookup (options, "disable-static-deltas", "b", &disable_static_deltas);
g_variant_lookup (options, "require-static-deltas", "b", &require_static_deltas);
}

if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
!disable_static_deltas && !require_static_deltas)
{
g_autoptr(GVariant) modified_options = NULL;
g_auto(GVariantDict) modified_options_dict;
g_variant_dict_init (&modified_options_dict, 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 0e04192

Please sign in to comment.