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

[Libguestfs] [PATCH] build: remove unreadable files after filtering



Move the removal of the files which don't exist or cannot be read, doing
it after the filtering with excludefiles and hostfiles files.
This avoid stat'ing files which will be excluded later anyway, hence
reducing the I/O during a supermin build phase.
---
 src/build.ml | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/build.ml b/src/build.ml
index b9b44ac..d7d0781 100644
--- a/src/build.ml
+++ b/src/build.ml
@@ -125,22 +125,6 @@ let rec build debug
   if debug >= 1 then
     printf "supermin: build: %d files\n%!" (List.length files);
 
-  (* Remove files from the list which don't exist on the host or are
-   * unreadable to us.
-   *)
-  let files =
-    List.filter (
-      fun file ->
-        try ignore (lstat file.ft_source_path); true
-        with Unix_error _ ->
-          try ignore (lstat file.ft_path); true
-          with Unix_error _ -> false
-    ) files in
-
-  if debug >= 1 then
-    printf "supermin: build: %d files, after removing unreadable files\n%!"
-      (List.length files);
-
   (* Remove excludefiles from the list.  Notes: (1) The current
    * implementation does not apply excludefiles to the base image.  (2)
    * The current implementation does not apply excludefiles to the
@@ -185,6 +169,22 @@ let rec build debug
     printf "supermin: build: %d files, after adding hostfiles\n%!"
       (List.length files);
 
+  (* Remove files from the list which don't exist on the host or are
+   * unreadable to us.
+   *)
+  let files =
+    List.filter (
+      fun file ->
+        try ignore (lstat file.ft_source_path); true
+        with Unix_error _ ->
+          try ignore (lstat file.ft_path); true
+          with Unix_error _ -> false
+    ) files in
+
+  if debug >= 1 then
+    printf "supermin: build: %d files, after removing unreadable files\n%!"
+      (List.length files);
+
   (* Difficult to explain what this does.  See comment below. *)
   let files = munge files in
 
-- 
2.1.0


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