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
  • Loading branch information
pwithnall committed Jun 6, 2018
1 parent b8d7b8f commit 57e032f
Showing 1 changed file with 44 additions and 7 deletions.
51 changes: 44 additions & 7 deletions src/libostree/ostree-repo-pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -3417,13 +3417,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 @@ -4541,6 +4541,43 @@ 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 (&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;
}

#ifdef OSTREE_ENABLE_EXPERIMENTAL_API

/* Structure used in ostree_repo_find_remotes_async() which stores metadata
Expand Down

0 comments on commit 57e032f

Please sign in to comment.