forked from Mirrors/flatpak-builder
repo-update: Disallow changing collection IDs
Emit an error message if the user tries to change the collection ID of an existing repository between two non-empty values. Allow them to set a collection ID where one was not set before. Changing the collection ID once it’s already been set will break updates for all clients who have previously pulled from the repository. If a developer really wants to change the collection ID for a repository, they’re going to have to recreate the repository from scratch. Signed-off-by: Philip Withnall <withnall@endlessm.com>tingping/wmclass
parent
5c0eef7bde
commit
b6828cda31
|
@ -441,9 +441,27 @@ flatpak_builtin_build_update_repo (int argc, char **argv,
|
|||
!flatpak_repo_set_default_branch (repo, opt_default_branch[0] ? opt_default_branch : NULL, error))
|
||||
return FALSE;
|
||||
|
||||
if (opt_collection_id &&
|
||||
!flatpak_repo_set_collection_id (repo, opt_collection_id[0] ? opt_collection_id : NULL, error))
|
||||
return FALSE;
|
||||
if (opt_collection_id != NULL)
|
||||
{
|
||||
/* Only allow a transition from no collection ID to a non-empty collection ID.
|
||||
* Changing the collection ID between two different non-empty values is too
|
||||
* dangerous: it will break all clients who have previously pulled from the repository.
|
||||
* Require the user to recreate the repository from scratch in that case. */
|
||||
#ifdef FLATPAK_ENABLE_P2P
|
||||
const char *old_collection_id = ostree_repo_get_collection_id (repo);
|
||||
#else /* if !FLATPAK_ENABLE_P2P */
|
||||
const char *old_collection_id = NULL;
|
||||
#endif /* !FLATPAK_ENABLE_P2P */
|
||||
const char *new_collection_id = opt_collection_id[0] ? opt_collection_id : NULL;
|
||||
|
||||
if (old_collection_id != NULL &&
|
||||
g_strcmp0 (old_collection_id, new_collection_id) != 0)
|
||||
return flatpak_fail (error, "The collection ID of an existing repository cannot be changed. "
|
||||
"Recreate the repository to change or clear its collection ID.");
|
||||
|
||||
if (!flatpak_repo_set_collection_id (repo, new_collection_id, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (opt_deploy_collection_id &&
|
||||
!flatpak_repo_set_deploy_collection_id (repo, TRUE, error))
|
||||
|
|
Loading…
Reference in New Issue