mirror of
https://github.com/flatpak/flatpak.git
synced 2026-03-12 12:08:08 -04:00
transaction: Always update metadata for remotes on update/install
All remotes involved in an update are updated before starting transaction.
This commit is contained in:
@@ -277,6 +277,9 @@ install_bundle (FlatpakDir *dir,
|
||||
if (!flatpak_transaction_add_install_bundle (transaction, file, gpg_data, error))
|
||||
return FALSE;
|
||||
|
||||
if (!flatpak_transaction_update_metadata (transaction, FALSE, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!flatpak_transaction_run (transaction, TRUE, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
|
||||
@@ -235,6 +235,9 @@ flatpak_builtin_update (int argc,
|
||||
}
|
||||
}
|
||||
|
||||
if (!flatpak_transaction_update_metadata (transaction, n_prefs == 0, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!flatpak_transaction_run (transaction, FALSE, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
|
||||
@@ -594,6 +594,51 @@ flatpak_transaction_add_update (FlatpakTransaction *self,
|
||||
return flatpak_transaction_add_ref (self, NULL, ref, subpaths, commit, FLATPAK_TRANSACTION_OP_KIND_UPDATE, NULL, NULL, error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_transaction_update_metadata (FlatpakTransaction *self,
|
||||
gboolean all_remotes,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_auto(GStrv) remotes = NULL;
|
||||
int i;
|
||||
GList *l;
|
||||
|
||||
/* Collect all dir+remotes used in this transaction */
|
||||
|
||||
if (all_remotes)
|
||||
{
|
||||
remotes = flatpak_dir_list_remotes (self->dir, NULL, error);
|
||||
if (remotes == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_autoptr(GHashTable) ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
for (l = self->ops; l != NULL; l = l->next)
|
||||
{
|
||||
FlatpakTransactionOp *op = l->data;
|
||||
g_hash_table_add (ht, g_strdup (op->remote));
|
||||
}
|
||||
remotes = (char **)g_hash_table_get_keys_as_array (ht, NULL);
|
||||
g_hash_table_steal_all (ht); /* Move ownership to remotes */
|
||||
}
|
||||
|
||||
/* Update metadata for said remotes */
|
||||
for (i = 0; remotes[i] != NULL; i++)
|
||||
{
|
||||
char *remote = remotes[i];
|
||||
|
||||
g_debug ("Updating remote metadata for %s", remote);
|
||||
if (!flatpak_dir_update_remote_configuration (self->dir, remote, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Reload changed configuration */
|
||||
if (!flatpak_dir_recreate_repo (self->dir, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_transaction_run (FlatpakTransaction *self,
|
||||
gboolean stop_on_first_error,
|
||||
|
||||
@@ -36,6 +36,10 @@ FlatpakTransaction *flatpak_transaction_new (FlatpakDir *dir,
|
||||
gboolean add_deps,
|
||||
gboolean add_related);
|
||||
void flatpak_transaction_free (FlatpakTransaction *self);
|
||||
gboolean flatpak_transaction_update_metadata (FlatpakTransaction *self,
|
||||
gboolean all_remotes,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean flatpak_transaction_run (FlatpakTransaction *self,
|
||||
gboolean stop_on_first_errror,
|
||||
GCancellable *cancellable,
|
||||
|
||||
@@ -7831,6 +7831,11 @@ flatpak_dir_update_remote_configuration (FlatpakDir *self,
|
||||
{
|
||||
g_autoptr(GVariant) summary = NULL;
|
||||
g_autoptr(GBytes) summary_sig_bytes = NULL;
|
||||
gboolean is_oci;
|
||||
|
||||
is_oci = flatpak_dir_get_remote_oci (self, remote);
|
||||
if (is_oci)
|
||||
return TRUE;
|
||||
|
||||
summary = fetch_remote_summary_file (self, remote, &summary_sig_bytes, cancellable, error);
|
||||
if (summary == NULL)
|
||||
@@ -7844,7 +7849,10 @@ flatpak_dir_update_remote_configuration (FlatpakDir *self,
|
||||
return FALSE;
|
||||
|
||||
if (summary_sig_bytes == NULL)
|
||||
return flatpak_fail (error, _("Can't update remote configuration as user, no GPG signature exist"));
|
||||
{
|
||||
g_debug ("Can't update remote configuration as user, no GPG signature)");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (has_changed)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user