mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-19 22:50:35 +03:00
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_tmp_name = NULL;
|
||||
ot_lfree char *resolved_commit = NULL;
|
||||
gs_free char *resolved_previous_commit = NULL;
|
||||
GError *temp_error = NULL;
|
||||
gboolean skip_checkout;
|
||||
|
||||
@ -423,6 +424,8 @@ deploy_tree (OtAdminDeploy *self,
|
||||
|
||||
if (!ostree_repo_resolve_rev (self->repo, revision, FALSE, &resolved_commit, error))
|
||||
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);
|
||||
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,
|
||||
resolved_commit, error))
|
||||
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,
|
||||
previous_deployment_revision, error))
|
||||
|
Loading…
x
Reference in New Issue
Block a user