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 authored and Colin Walters committed 2015-03-25 17:24:05 -04:00
1 parent a25c7fab12
commit 7941189dfd
2 files changed
+16

No files matched your search

+14
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;
}
+2
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);