admin: Don't overwrite previous ref unless it's different
We shouldn't overwrite deploy/<osname>/previous unless we actually have something new. This fixes the bug where two consecutive: $ ostree admin upgrade foo $ ostree admin upgrade foo would end up pruning the data for foo/previous from the repo.
This commit is contained in:
parent
59c98d0a04
commit
64934202e4
|
|
@ -404,6 +404,7 @@ deploy_tree (OtAdminDeploy *self,
|
||||||
ot_lfree char *checkout_target_name = NULL;
|
ot_lfree char *checkout_target_name = NULL;
|
||||||
ot_lfree char *checkout_target_tmp_name = NULL;
|
ot_lfree char *checkout_target_tmp_name = NULL;
|
||||||
ot_lfree char *resolved_commit = NULL;
|
ot_lfree char *resolved_commit = NULL;
|
||||||
|
gs_free char *resolved_previous_commit = NULL;
|
||||||
GError *temp_error = NULL;
|
GError *temp_error = NULL;
|
||||||
gboolean skip_checkout;
|
gboolean skip_checkout;
|
||||||
|
|
||||||
|
|
@ -423,6 +424,8 @@ deploy_tree (OtAdminDeploy *self,
|
||||||
|
|
||||||
if (!ostree_repo_resolve_rev (self->repo, revision, FALSE, &resolved_commit, error))
|
if (!ostree_repo_resolve_rev (self->repo, revision, FALSE, &resolved_commit, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
if (!ostree_repo_resolve_rev (self->repo, revision, TRUE, &resolved_previous_commit, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
root = (OstreeRepoFile*)ostree_repo_file_new_root (self->repo, resolved_commit);
|
root = (OstreeRepoFile*)ostree_repo_file_new_root (self->repo, resolved_commit);
|
||||||
if (!ostree_repo_file_ensure_resolved (root, error))
|
if (!ostree_repo_file_ensure_resolved (root, error))
|
||||||
|
|
@ -561,7 +564,10 @@ deploy_tree (OtAdminDeploy *self,
|
||||||
if (!ostree_repo_write_ref (self->repo, NULL, current_deployment_ref,
|
if (!ostree_repo_write_ref (self->repo, NULL, current_deployment_ref,
|
||||||
resolved_commit, error))
|
resolved_commit, error))
|
||||||
goto out;
|
goto out;
|
||||||
if (previous_deployment_revision != NULL)
|
/* Only overwrite previous if it's different from what we're deploying now.
|
||||||
|
*/
|
||||||
|
if (resolved_previous_commit != NULL
|
||||||
|
&& strcmp (resolved_previous_commit, resolved_commit) != 0)
|
||||||
{
|
{
|
||||||
if (!ostree_repo_write_ref (self->repo, NULL, previous_deployment_ref,
|
if (!ostree_repo_write_ref (self->repo, NULL, previous_deployment_ref,
|
||||||
previous_deployment_revision, error))
|
previous_deployment_revision, error))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue