Switch to libgsystem directory creation API
More code being dropped into a common place.
This commit is contained in:
parent
6d81120455
commit
f3d765c903
|
|
@ -1 +1 @@
|
|||
Subproject commit 1332d9713365a53fae76570a3c484753f9bcbb30
|
||||
Subproject commit ab2588da8442fc6135af13ee624dd91b73a7051c
|
||||
|
|
@ -477,7 +477,7 @@ write_checksum_file (GFile *parentdir,
|
|||
{
|
||||
child = g_file_get_child (parent, (char*)components->pdata[i]);
|
||||
|
||||
if (!ot_gfile_ensure_directory (child, FALSE, error))
|
||||
if (!gs_file_ensure_directory (child, FALSE, NULL, error))
|
||||
goto out;
|
||||
|
||||
g_clear_object (&parent);
|
||||
|
|
@ -622,7 +622,7 @@ ostree_repo_check (OstreeRepo *self, GError **error)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (!ot_gfile_ensure_directory (self->pending_dir, FALSE, error))
|
||||
if (!gs_file_ensure_directory (self->pending_dir, FALSE, NULL, error))
|
||||
goto out;
|
||||
|
||||
self->config = g_key_file_new ();
|
||||
|
|
@ -785,7 +785,7 @@ commit_loose_object_impl (OstreeRepo *self,
|
|||
ot_lobj GFile *parent = NULL;
|
||||
|
||||
parent = g_file_get_parent (dest);
|
||||
if (!ot_gfile_ensure_directory (parent, FALSE, error))
|
||||
if (!gs_file_ensure_directory (parent, FALSE, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (is_regular)
|
||||
|
|
@ -1849,7 +1849,7 @@ ostree_repo_write_ref (OstreeRepo *self,
|
|||
{
|
||||
dir = g_file_get_child (self->remote_heads_dir, remote);
|
||||
|
||||
if (!ot_gfile_ensure_directory (dir, FALSE, error))
|
||||
if (!gs_file_ensure_directory (dir, FALSE, NULL, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -3400,7 +3400,7 @@ checkout_file_thread (GSimpleAsyncResult *result,
|
|||
goto out;
|
||||
|
||||
objdir = g_file_get_parent (loose_path);
|
||||
if (!ot_gfile_ensure_directory (objdir, TRUE, error))
|
||||
if (!gs_file_ensure_directory (objdir, TRUE, cancellable, error))
|
||||
{
|
||||
g_prefix_error (error, "Creating cache directory %s: ",
|
||||
gs_file_get_path_cached (objdir));
|
||||
|
|
|
|||
|
|
@ -49,45 +49,6 @@ ot_gfile_type_for_mode (guint32 mode)
|
|||
return G_FILE_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
gboolean
|
||||
ot_gfile_ensure_directory (GFile *dir,
|
||||
gboolean with_parents,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GError *temp_error = NULL;
|
||||
|
||||
if (!g_file_make_directory (dir, NULL, &temp_error))
|
||||
{
|
||||
if (with_parents &&
|
||||
g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
||||
{
|
||||
ot_lobj GFile *parent = NULL;
|
||||
|
||||
g_clear_error (&temp_error);
|
||||
|
||||
parent = g_file_get_parent (dir);
|
||||
if (parent)
|
||||
{
|
||||
if (!ot_gfile_ensure_directory (parent, TRUE, error))
|
||||
goto out;
|
||||
}
|
||||
if (!ot_gfile_ensure_directory (dir, FALSE, error))
|
||||
goto out;
|
||||
}
|
||||
else if (!g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
|
||||
{
|
||||
g_propagate_error (error, temp_error);
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
g_clear_error (&temp_error);
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
GFile *
|
||||
ot_gfile_from_build_path (const char *first, ...)
|
||||
|
|
@ -220,7 +181,7 @@ cp_internal (GFile *src,
|
|||
if (!enumerator)
|
||||
goto out;
|
||||
|
||||
if (!ot_gfile_ensure_directory (dest, FALSE, error))
|
||||
if (!gs_file_ensure_directory (dest, FALSE, cancellable, error))
|
||||
goto out;
|
||||
|
||||
while ((file_info = g_file_enumerator_next_file (enumerator, cancellable, &temp_error)) != NULL)
|
||||
|
|
@ -231,7 +192,7 @@ cp_internal (GFile *src,
|
|||
|
||||
if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
|
||||
{
|
||||
if (!ot_gfile_ensure_directory (dest_child, FALSE, error))
|
||||
if (!gs_file_ensure_directory (dest_child, FALSE, cancellable, error))
|
||||
goto out;
|
||||
|
||||
/* Can't do this even though we'd like to; it fails with an error about
|
||||
|
|
|
|||
|
|
@ -42,8 +42,6 @@ GFile *ot_gfile_get_child_strconcat (GFile *parent, const char *first, ...) G_GN
|
|||
|
||||
GFile *ot_gfile_get_child_build_path (GFile *parent, const char *first, ...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
gboolean ot_gfile_ensure_directory (GFile *dir, gboolean with_parents, GError **error);
|
||||
|
||||
gboolean ot_gfile_load_contents_utf8 (GFile *file,
|
||||
char **contents_out,
|
||||
char **etag_out,
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ copy_one_config_file (OtAdminDeploy *self,
|
|||
parent = g_file_get_parent (dest);
|
||||
|
||||
/* FIXME actually we need to copy permissions and xattrs */
|
||||
if (!ot_gfile_ensure_directory (parent, TRUE, error))
|
||||
if (!gs_file_ensure_directory (parent, TRUE, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!g_file_copy (src, dest, G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS | G_FILE_COPY_ALL_METADATA,
|
||||
|
|
@ -392,7 +392,7 @@ deploy_tree (OtAdminDeploy *self,
|
|||
deploy_target_path_tmp = g_file_resolve_relative_path (deploy_dir, deploy_target_fullname_tmp);
|
||||
|
||||
deploy_parent = g_file_get_parent (deploy_target_path);
|
||||
if (!ot_gfile_ensure_directory (deploy_parent, TRUE, error))
|
||||
if (!gs_file_ensure_directory (deploy_parent, TRUE, cancellable, error))
|
||||
goto out;
|
||||
|
||||
deploy_target_etc_name = g_strconcat (deploy_target, "-", resolved_commit, "-etc", NULL);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ copy_modules (OtAdminUpdateKernel *self,
|
|||
src_modules_file = ot_gfile_from_build_path ("/lib/modules", release, NULL);
|
||||
dest_modules_file = ot_gfile_get_child_build_path (self->ostree_dir, "modules", release, NULL);
|
||||
dest_modules_parent = g_file_get_parent (dest_modules_file);
|
||||
if (!ot_gfile_ensure_directory (dest_modules_parent, FALSE, error))
|
||||
if (!gs_file_ensure_directory (dest_modules_parent, FALSE, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!g_file_query_exists (dest_modules_file, cancellable))
|
||||
|
|
|
|||
|
|
@ -36,17 +36,17 @@ ot_admin_ensure_initialized (GFile *ostree_dir,
|
|||
|
||||
g_clear_object (&dir);
|
||||
dir = g_file_get_child (ostree_dir, "repo");
|
||||
if (!ot_gfile_ensure_directory (dir, TRUE, error))
|
||||
if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
|
||||
goto out;
|
||||
|
||||
g_clear_object (&dir);
|
||||
dir = g_file_get_child (ostree_dir, "deploy");
|
||||
if (!ot_gfile_ensure_directory (dir, TRUE, error))
|
||||
if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
|
||||
goto out;
|
||||
|
||||
g_clear_object (&dir);
|
||||
dir = g_file_get_child (ostree_dir, "modules");
|
||||
if (!ot_gfile_ensure_directory (dir, TRUE, error))
|
||||
if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
|
||||
goto out;
|
||||
|
||||
g_clear_object (&dir);
|
||||
|
|
@ -70,12 +70,12 @@ ot_admin_ensure_initialized (GFile *ostree_dir,
|
|||
*/
|
||||
g_clear_object (&dir);
|
||||
dir = ot_gfile_get_child_build_path (ostree_dir, "var", "log", NULL);
|
||||
if (!ot_gfile_ensure_directory (dir, TRUE, error))
|
||||
if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
|
||||
goto out;
|
||||
|
||||
g_clear_object (&dir);
|
||||
dir = ot_gfile_get_child_build_path (ostree_dir, "var", "tmp", NULL);
|
||||
if (!ot_gfile_ensure_directory (dir, TRUE, error))
|
||||
if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
|
||||
goto out;
|
||||
if (chmod (gs_file_get_path_cached (dir), 01777) < 0)
|
||||
{
|
||||
|
|
@ -85,7 +85,7 @@ ot_admin_ensure_initialized (GFile *ostree_dir,
|
|||
|
||||
g_clear_object (&dir);
|
||||
dir = ot_gfile_get_child_build_path (ostree_dir, "var", "lib", NULL);
|
||||
if (!ot_gfile_ensure_directory (dir, TRUE, error))
|
||||
if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
|
||||
goto out;
|
||||
|
||||
g_clear_object (&dir);
|
||||
|
|
|
|||
Loading…
Reference in New Issue