* not being pulled will be ignored and any ref without a keyring remote
* will be verified with the keyring of the remote being pulled from.
* Since: 2019.2
+ * * `summary-bytes` (`ay'): Contents of the `summary` file to use. If this is
+ * specified, `summary-sig-bytes` must also be specified. This is
+ * useful if doing multiple pull operations in a transaction, using
+ * ostree_repo_remote_fetch_summary_with_options() beforehand to download
+ * the `summary` and `summary.sig` once for the entire transaction. If not
+ * specified, the `summary` will be downloaded from the remote. Since: 2020.5
+ * * `summary-sig-bytes` (`ay`): Contents of the `summary.sig` file. If this
+ * is specified, `summary-bytes` must also be specified. Since: 2020.5
*/
gboolean
ostree_repo_pull_with_options (OstreeRepo *self,
int i;
g_autofree char **opt_localcache_repos = NULL;
g_autoptr(GVariantIter) ref_keyring_map_iter = NULL;
+ g_autoptr(GVariant) summary_bytes_v = NULL;
+ g_autoptr(GVariant) summary_sig_bytes_v = NULL;
/* If refs or collection-refs has exactly one value, this will point to that
* value, otherwise NULL. Used for logging.
*/
g_variant_lookup (options, "n-network-retries", "u", &pull_data->n_network_retries);
opt_ref_keyring_map_set =
g_variant_lookup (options, "ref-keyring-map", "a(sss)", &ref_keyring_map_iter);
+ (void) g_variant_lookup (options, "summary-bytes", "@ay", &summary_bytes_v);
+ (void) g_variant_lookup (options, "summary-sig-bytes", "@ay", &summary_sig_bytes_v);
if (pull_data->remote_refspec_name != NULL)
pull_data->remote_name = g_strdup (pull_data->remote_refspec_name);
*/
g_return_val_if_fail (!pull_data->dry_run || pull_data->require_static_deltas, FALSE);
+ /* summary-bytes and summary-sig-bytes must both be specified, or neither be
+ * specified, so we know they’re consistent */
+ g_return_val_if_fail ((summary_bytes_v == NULL) == (summary_sig_bytes_v == NULL), FALSE);
+
pull_data->is_mirror = (flags & OSTREE_REPO_PULL_FLAGS_MIRROR) > 0;
pull_data->is_commit_only = (flags & OSTREE_REPO_PULL_FLAGS_COMMIT_ONLY) > 0;
/* See our processing of OSTREE_REPO_PULL_FLAGS_UNTRUSTED below */
if (!metalink_uri)
goto out;
+ /* FIXME: Use summary_bytes_v/summary_sig_bytes_v to avoid unnecessary
+ * re-downloads here. Would require additional support for caching the
+ * metalink file or mirror list. */
+
metalink = _ostree_metalink_new (pull_data->fetcher, "summary",
OSTREE_MAX_METADATA_SIZE, metalink_uri,
pull_data->n_network_retries);
g_autoptr(GVariant) additional_metadata = NULL;
gboolean summary_from_cache = FALSE;
- if (!pull_data->summary_data_sig)
+ if (summary_sig_bytes_v)
+ {
+ /* Must both be specified */
+ g_assert (summary_bytes_v);
+
+ bytes_sig = g_variant_get_data_as_bytes (summary_sig_bytes_v);
+ bytes_summary = g_variant_get_data_as_bytes (summary_bytes_v);
+
+ if (!bytes_sig || !bytes_summary)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "summary-bytes or summary-sig-bytes set to invalid value");
+ goto out;
+ }
+
+ g_debug ("Loaded %s summary from options", remote_name_or_baseurl);
+ }
+
+ if (!bytes_sig)
{
if (!_ostree_fetcher_mirrored_request_to_membuf (pull_data->fetcher,
pull_data->meta_mirrorlist,
}
if (bytes_sig &&
+ !bytes_summary &&
!pull_data->remote_repo_local &&
!_ostree_repo_load_cache_summary_if_same_sig (self,
remote_name_or_baseurl,
error))
goto out;
- if (bytes_summary)
+ if (bytes_summary && !summary_bytes_v)
{
g_debug ("Loaded %s summary from cache", remote_name_or_baseurl);
summary_from_cache = TRUE;