lib/repo: Add return value to _ostree_repo_add_remote()

Return whether the remote already existed. This is an internal API, so
it’s not an API break. The return value will be useful in upcoming
commits for working out whether to later remove a remote again.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #875
Approved by: cgwalters
This commit is contained in:
Philip Withnall 2017-05-18 08:26:34 +01:00 committed by Atomic Bot
parent ed7905d000
commit b6ac28b0da
2 changed files with 10 additions and 6 deletions

View File

@ -351,7 +351,7 @@ gboolean
_ostree_repo_update_mtime (OstreeRepo *self,
GError **error);
void
gboolean
_ostree_repo_add_remote (OstreeRepo *self,
OstreeRemote *remote);
OstreeRemote *

View File

@ -150,19 +150,23 @@ _ostree_repo_get_remote_inherited (OstreeRepo *self,
return g_steal_pointer (&remote);
}
void
gboolean
_ostree_repo_add_remote (OstreeRepo *self,
OstreeRemote *remote)
{
g_return_if_fail (self != NULL);
g_return_if_fail (remote != NULL);
g_return_if_fail (remote->name != NULL);
gboolean already_existed;
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (remote != NULL, FALSE);
g_return_val_if_fail (remote->name != NULL, FALSE);
g_mutex_lock (&self->remotes_lock);
g_hash_table_replace (self->remotes, remote->name, ostree_remote_ref (remote));
already_existed = g_hash_table_replace (self->remotes, remote->name, ostree_remote_ref (remote));
g_mutex_unlock (&self->remotes_lock);
return already_existed;
}
static gboolean