Add deploy refs for currently deployed commit.

When we deploy e.g. app/org.foo.bar/x86_64/stable, then we
also create a deploy/app/org.foo.bar/x86_64/stable ref pointing to
the latest deployed commit. We also remove it when an app is uninstalled.

This means that a prune operation will not delete objects that are deployed
(which would not save any space anyway). This is nice because this can
happen for instance when you flatpak update --no-deploy.

Fixes https://github.com/flatpak/flatpak/issues/2085

Closes: #2563
Approved by: alexlarsson
This commit is contained in:
Alexander Larsson
2019-01-11 15:29:53 +01:00
committed by Atomic Bot
parent 379e6145e8
commit cb30e7ef4e

View File

@@ -6846,6 +6846,22 @@ apply_extra_data (FlatpakDir *self,
return TRUE;
}
/* We create a deploy ref for the currently deployed version of all refs to avoid
deployed commits being pruned when e.g. we pull --no-deploy. */
static gboolean
flatpak_dir_update_deploy_ref (FlatpakDir *self,
const char *ref,
const char *checksum,
GError **error)
{
g_autofree char *deploy_ref = g_strconcat ("deploy/", ref, NULL);
if (!ostree_repo_set_ref_immediate (self->repo, NULL, deploy_ref, checksum, NULL, error))
return FALSE;
return TRUE;
}
gboolean
flatpak_dir_deploy (FlatpakDir *self,
const char *origin,
@@ -7280,6 +7296,9 @@ flatpak_dir_deploy (FlatpakDir *self,
if (!flatpak_dir_set_active (self, ref, checkout_basename, cancellable, error))
return FALSE;
if (!flatpak_dir_update_deploy_ref (self, ref, checksum, error))
return FALSE;
return TRUE;
}
@@ -8600,6 +8619,9 @@ flatpak_dir_uninstall (FlatpakDir *self,
}
}
if (!flatpak_dir_update_deploy_ref (self, ref, NULL, error))
return FALSE;
if (!flatpak_dir_undeploy_all (self, ref, force_remove, &was_deployed, cancellable, error))
return FALSE;