Add ostree_ensure_repo_writable()

Commands that need to write files within the repo directory can call
this early to ensure the directory is writable for the current user.
If not, it fails with a helpful "You need to be root to perform this
command" message.
This commit is contained in:
Matthew Barnes 2015-01-16 10:04:18 -05:00 committed by Colin Walters
parent a25c7fab12
commit 7941189dfd
2 changed files with 16 additions and 0 deletions

View File

@ -360,3 +360,17 @@ ostree_admin_option_context_parse (GOptionContext *context,
out:
return success;
}
gboolean
ostree_ensure_repo_writable (OstreeRepo *repo,
GError **error)
{
gboolean ret;
ret = ostree_repo_is_writable (repo, error);
g_prefix_error (error, "Cannot write to repository: ");
return ret;
}

View File

@ -51,3 +51,5 @@ gboolean ostree_admin_option_context_parse (GOptionContext *context,
int *argc, char ***argv,
OstreeSysroot **out_sysroot,
GCancellable *cancellable, GError **error);
gboolean ostree_ensure_repo_writable (OstreeRepo *repo, GError **error);