lib/remote: Add arguments to internal OstreeRemote constructor
Add a name argument to the internal OstreeRemote constructor, since this member (and several derived from it) is non-nullable, and hence must always be set at construction time. This changes the only call sites of the constructor to use the new API, which is internal. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #875 Approved by: cgwalters
This commit is contained in:
parent
2910b88081
commit
ed7905d000
|
|
@ -46,7 +46,7 @@ struct OstreeRemote {
|
||||||
};
|
};
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
OstreeRemote *ostree_remote_new (void);
|
OstreeRemote *ostree_remote_new (const gchar *name);
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
OstreeRemote *ostree_remote_new_from_keyfile (GKeyFile *keyfile,
|
OstreeRemote *ostree_remote_new_from_keyfile (GKeyFile *keyfile,
|
||||||
|
|
|
||||||
|
|
@ -53,12 +53,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
OstreeRemote *
|
OstreeRemote *
|
||||||
ostree_remote_new (void)
|
ostree_remote_new (const gchar *name)
|
||||||
{
|
{
|
||||||
OstreeRemote *remote;
|
OstreeRemote *remote;
|
||||||
|
|
||||||
|
g_return_val_if_fail (name != NULL && *name != '\0', NULL);
|
||||||
|
|
||||||
remote = g_slice_new0 (OstreeRemote);
|
remote = g_slice_new0 (OstreeRemote);
|
||||||
remote->ref_count = 1;
|
remote->ref_count = 1;
|
||||||
|
remote->name = g_strdup (name);
|
||||||
|
remote->group = g_strdup_printf ("remote \"%s\"", name);
|
||||||
|
remote->keyring = g_strdup_printf ("%s.trustedkeys.gpg", name);
|
||||||
remote->options = g_key_file_new ();
|
remote->options = g_key_file_new ();
|
||||||
|
|
||||||
return remote;
|
return remote;
|
||||||
|
|
@ -70,6 +75,7 @@ ostree_remote_new_from_keyfile (GKeyFile *keyfile,
|
||||||
{
|
{
|
||||||
g_autoptr(GMatchInfo) match = NULL;
|
g_autoptr(GMatchInfo) match = NULL;
|
||||||
OstreeRemote *remote;
|
OstreeRemote *remote;
|
||||||
|
g_autofree gchar *name = NULL;
|
||||||
|
|
||||||
static gsize regex_initialized;
|
static gsize regex_initialized;
|
||||||
static GRegex *regex;
|
static GRegex *regex;
|
||||||
|
|
@ -88,10 +94,8 @@ ostree_remote_new_from_keyfile (GKeyFile *keyfile,
|
||||||
if (!g_regex_match (regex, group, 0, &match))
|
if (!g_regex_match (regex, group, 0, &match))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
remote = ostree_remote_new ();
|
name = g_match_info_fetch (match, 1);
|
||||||
remote->name = g_match_info_fetch (match, 1);
|
remote = ostree_remote_new (name);
|
||||||
remote->group = g_strdup (group);
|
|
||||||
remote->keyring = g_strdup_printf ("%s.trustedkeys.gpg", remote->name);
|
|
||||||
|
|
||||||
ot_keyfile_copy_group (keyfile, remote->options, group);
|
ot_keyfile_copy_group (keyfile, remote->options, group);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -882,10 +882,7 @@ impl_repo_remote_add (OstreeRepo *self,
|
||||||
name, remote->file ? gs_file_get_path_cached (remote->file) : "(in config)");
|
name, remote->file ? gs_file_get_path_cached (remote->file) : "(in config)");
|
||||||
}
|
}
|
||||||
|
|
||||||
remote = ostree_remote_new ();
|
remote = ostree_remote_new (name);
|
||||||
remote->name = g_strdup (name);
|
|
||||||
remote->group = g_strdup_printf ("remote \"%s\"", name);
|
|
||||||
remote->keyring = g_strdup_printf ("%s.trustedkeys.gpg", name);
|
|
||||||
|
|
||||||
/* The OstreeRepo maintains its own internal system root path,
|
/* The OstreeRepo maintains its own internal system root path,
|
||||||
* so we need to not only check if a "sysroot" argument was given
|
* so we need to not only check if a "sysroot" argument was given
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue