[ostree] Switch to libgsystem directory creation API



commit f3d765c9032a02a32be9af5725c27af09494cc5a
Author: Colin Walters <walters verbum org>
Date:   Thu Nov 29 16:40:17 2012 -0500

    Switch to libgsystem directory creation API
    
    More code being dropped into a common place.

 src/libgsystem                              |    2 +-
 src/libostree/ostree-repo.c                 |   10 +++---
 src/libotutil/ot-gio-utils.c                |   43 +-------------------------
 src/libotutil/ot-gio-utils.h                |    2 -
 src/ostree/ot-admin-builtin-deploy.c        |    4 +-
 src/ostree/ot-admin-builtin-update-kernel.c |    2 +-
 src/ostree/ot-admin-functions.c             |   12 ++++----
 7 files changed, 17 insertions(+), 58 deletions(-)
---
diff --git a/src/libgsystem b/src/libgsystem
index 1332d97..ab2588d 160000
--- a/src/libgsystem
+++ b/src/libgsystem
@@ -1 +1 @@
-Subproject commit 1332d9713365a53fae76570a3c484753f9bcbb30
+Subproject commit ab2588da8442fc6135af13ee624dd91b73a7051c
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index f3c2690..d48ebd5 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -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));
diff --git a/src/libotutil/ot-gio-utils.c b/src/libotutil/ot-gio-utils.c
index 14af2ce..1130225 100644
--- a/src/libotutil/ot-gio-utils.c
+++ b/src/libotutil/ot-gio-utils.c
@@ -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
diff --git a/src/libotutil/ot-gio-utils.h b/src/libotutil/ot-gio-utils.h
index b96f1ca..2481698 100644
--- a/src/libotutil/ot-gio-utils.h
+++ b/src/libotutil/ot-gio-utils.h
@@ -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,
diff --git a/src/ostree/ot-admin-builtin-deploy.c b/src/ostree/ot-admin-builtin-deploy.c
index 27b7ce7..e7681b9 100644
--- a/src/ostree/ot-admin-builtin-deploy.c
+++ b/src/ostree/ot-admin-builtin-deploy.c
@@ -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);
diff --git a/src/ostree/ot-admin-builtin-update-kernel.c b/src/ostree/ot-admin-builtin-update-kernel.c
index 0629bfe..b944d0e 100644
--- a/src/ostree/ot-admin-builtin-update-kernel.c
+++ b/src/ostree/ot-admin-builtin-update-kernel.c
@@ -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))
diff --git a/src/ostree/ot-admin-functions.c b/src/ostree/ot-admin-functions.c
index 6ddb768..c291e9e 100644
--- a/src/ostree/ot-admin-functions.c
+++ b/src/ostree/ot-admin-functions.c
@@ -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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]