From 7896bcbe6595e4dd076a06a024d058193fa0f09c Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 10 May 2017 21:43:26 -0400 Subject: [PATCH] lib/checkout: Move special case for subpath of file to toplevel Since we now have a cleaner separation of "toplevel checkout prep" versus "recursive checkout", handle the special case of checking out a single file at first rather than later. Prep for future work in optimizing this function more. Closes: #848 Approved by: jlebon --- src/libostree/ostree-repo-checkout.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libostree/ostree-repo-checkout.c b/src/libostree/ostree-repo-checkout.c index 50967769..9c1420ee 100644 --- a/src/libostree/ostree-repo-checkout.c +++ b/src/libostree/ostree-repo-checkout.c @@ -666,15 +666,6 @@ checkout_tree_at_recurse (OstreeRepo *self, return FALSE; } - /* Note early return here! */ - if (g_file_info_get_file_type (source_info) != G_FILE_TYPE_DIRECTORY) - return checkout_one_file_at (self, options, state, - (GFile *) source, - source_info, - destination_dfd, - g_file_info_get_name (source_info), - cancellable, error); - g_autoptr(GFileEnumerator) dir_enum = g_file_enumerate_children ((GFile*)source, OSTREE_GIO_FAST_QUERYINFO, @@ -789,6 +780,15 @@ checkout_tree_at (OstreeRepo *self, g_assert (options->force_copy); } + /* Special case handling for subpath of a non-directory */ + if (g_file_info_get_file_type (source_info) != G_FILE_TYPE_DIRECTORY) + return checkout_one_file_at (self, options, &state, + (GFile *) source, + source_info, + destination_parent_fd, + g_file_info_get_name (source_info), + cancellable, error); + /* Cache any directory metadata we read during this operation; * see commit b7afe91e21143d7abb0adde440683a52712aa246 */