You will now see an error such as:
$ virt-customize -a centos-6.img --truncate-recursive /home/foo
[ 0.0] Examining the guest ...
[ 16.5] Setting a random seed
[ 16.5] Recursively truncating: /home/foo
virt-customize: error: libguestfs error: find0: /home/foo: No such file or
directory
Thanks: Xianghua Chen
---
mllib/common_utils.ml | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index dfffae3..9765a79 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -779,12 +779,10 @@ let rm_rf_only_files (g : Guestfs.guestfs) ?filter dir =
)
let truncate_recursive (g : Guestfs.guestfs) dir =
- if g#is_dir dir then (
- let files = Array.map (Filename.concat dir) (g#find dir) in
- let files = Array.to_list files in
- let files = List.filter g#is_file files in
- List.iter g#truncate files
- )
+ let files = Array.map (Filename.concat dir) (g#find dir) in
+ let files = Array.to_list files in
+ let files = List.filter g#is_file files in
+ List.iter g#truncate files
(* Detect type of a file. *)
let detect_file_type filename =
--
2.7.4