pull: Also skip partial commits for deltas if no summary file
I was playing around in a FAH vagrant box, and hit: ``` Receiving delta parts: 3/4 453.2 kB/s 1.8 MB/145.8 MB error: opcode set-read-source: No such file object b6e54ba3471b9c116ce6b9bfbf9e55fec60d35cfdb9ae5ae1ee219af02a591b7 ``` This is because this host version doesn't yet have https://github.com/ostreedev/ostree/pull/710 which incidentally fixed this for the case where the OS vendor is using summary files. Some organizations may not be using summary files - at least we still try to support that case. So let's copy the logic very recently added in that commit to handle the legacy case too. No new tests since this is a nice-to-have - we really do expect people to be using summary files now. Closes: #739 Approved by: jlebon
This commit is contained in:
parent
3b09620c27
commit
79c3eb63be
|
|
@ -1197,6 +1197,14 @@ gpg_verify_unwritten_commit (OtPullData *pull_data,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
commitstate_is_partial (OtPullData *pull_data,
|
||||||
|
OstreeRepoCommitState commitstate)
|
||||||
|
{
|
||||||
|
return pull_data->legacy_transaction_resuming
|
||||||
|
|| (commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
scan_commit_object (OtPullData *pull_data,
|
scan_commit_object (OtPullData *pull_data,
|
||||||
const char *checksum,
|
const char *checksum,
|
||||||
|
|
@ -1253,8 +1261,7 @@ scan_commit_object (OtPullData *pull_data,
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* If we found a legacy transaction flag, assume all commits are partial */
|
/* If we found a legacy transaction flag, assume all commits are partial */
|
||||||
is_partial = pull_data->legacy_transaction_resuming
|
is_partial = commitstate_is_partial (pull_data, commitstate);
|
||||||
|| (commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL) > 0;
|
|
||||||
|
|
||||||
/* PARSE OSTREE_SERIALIZED_COMMIT_VARIANT */
|
/* PARSE OSTREE_SERIALIZED_COMMIT_VARIANT */
|
||||||
g_variant_get_child (commit, 1, "@ay", &parent_csum);
|
g_variant_get_child (commit, 1, "@ay", &parent_csum);
|
||||||
|
|
@ -3242,6 +3249,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||||
g_autofree char *from_revision = NULL;
|
g_autofree char *from_revision = NULL;
|
||||||
const char *ref = key;
|
const char *ref = key;
|
||||||
const char *to_revision = value;
|
const char *to_revision = value;
|
||||||
|
gboolean have_valid_from_commit = TRUE;
|
||||||
|
|
||||||
/* If we have a summary, find the latest local commit we have
|
/* If we have a summary, find the latest local commit we have
|
||||||
* to use as a from revision for static deltas.
|
* to use as a from revision for static deltas.
|
||||||
|
|
@ -3257,9 +3265,27 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||||
if (!ostree_repo_resolve_rev (pull_data->repo, ref, TRUE,
|
if (!ostree_repo_resolve_rev (pull_data->repo, ref, TRUE,
|
||||||
&from_revision, error))
|
&from_revision, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
/* Determine whether the from revision we have is partial; this
|
||||||
|
* can happen if e.g. one uses `ostree pull --commit-metadata-only`.
|
||||||
|
* This mirrors the logic in get_best_static_delta_start_for().
|
||||||
|
*/
|
||||||
|
if (from_revision)
|
||||||
|
{
|
||||||
|
OstreeRepoCommitState from_commitstate;
|
||||||
|
|
||||||
|
if (!ostree_repo_load_commit (pull_data->repo, from_revision, NULL,
|
||||||
|
&from_commitstate, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
/* Was it partial? OK, we can't use it. */
|
||||||
|
if (commitstate_is_partial (pull_data, from_commitstate))
|
||||||
|
have_valid_from_commit = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!disable_static_deltas &&
|
if (!disable_static_deltas &&
|
||||||
|
have_valid_from_commit &&
|
||||||
(from_revision == NULL || g_strcmp0 (from_revision, to_revision) != 0))
|
(from_revision == NULL || g_strcmp0 (from_revision, to_revision) != 0))
|
||||||
{
|
{
|
||||||
g_autofree char *delta_name =
|
g_autofree char *delta_name =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue