[ostree] core: Make local-clone handle nested refs/heads directories



commit 8d935f46c451e32185e7a15a31735cdff62d0896
Author: Colin Walters <walters verbum org>
Date:   Sat Jan 7 11:26:12 2012 -0500

    core: Make local-clone handle nested refs/heads directories

 src/ostree/ot-builtin-local-clone.c |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/src/ostree/ot-builtin-local-clone.c b/src/ostree/ot-builtin-local-clone.c
index f1a6e1b..3aad00d 100644
--- a/src/ostree/ot-builtin-local-clone.c
+++ b/src/ostree/ot-builtin-local-clone.c
@@ -39,10 +39,10 @@ typedef struct {
 } OtLocalCloneData;
 
 static gboolean
-copy_dir_contents (GFile  *src,
-                   GFile  *dest,
-                   GCancellable *cancellable,
-                   GError   **error)
+copy_dir_contents_recurse (GFile  *src,
+                           GFile  *dest,
+                           GCancellable *cancellable,
+                           GError   **error)
 {
   gboolean ret = FALSE;
   GFile *child_src = NULL;
@@ -65,9 +65,20 @@ copy_dir_contents (GFile  *src,
       g_clear_object (&child_dest);
       child_dest = g_file_get_child (dest, name);
 
-      if (!g_file_copy (child_src, child_dest, G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS,
-                        cancellable, NULL, NULL, error))
-        goto out;
+      if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
+        {
+          if (!ot_gfile_ensure_directory (child_dest, FALSE, error))
+            goto out;
+          
+          if (!copy_dir_contents_recurse (child_src, child_dest, cancellable, error))
+            goto out;
+        }
+      else
+        {
+          if (!g_file_copy (child_src, child_dest, G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS,
+                            cancellable, NULL, NULL, error))
+            goto out;
+        }
       
       g_clear_object (&file_info);
     }
@@ -230,14 +241,14 @@ ostree_builtin_local_clone (int argc, char **argv, GFile *repo_path, GError **er
   
   src_dir = g_file_resolve_relative_path (src_repo_dir, "refs/heads");
   dest_dir = g_file_resolve_relative_path (dest_repo_dir, "refs/heads");
-  if (!copy_dir_contents (src_dir, dest_dir, NULL, error))
+  if (!copy_dir_contents_recurse (src_dir, dest_dir, NULL, error))
     goto out;
   g_clear_object (&src_dir);
   g_clear_object (&dest_dir);
 
   src_dir = g_file_resolve_relative_path (src_repo_dir, "tags");
   dest_dir = g_file_resolve_relative_path (dest_repo_dir, "tags");
-  if (!copy_dir_contents (src_dir, dest_dir, NULL, error))
+  if (!copy_dir_contents_recurse (src_dir, dest_dir, NULL, error))
     goto out;
 
   ret = TRUE;



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