[Pkg-libvirt-commits] [libguestfs] 37/63: v2v: -i disk: Don't fail if filename has no extension.

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:43:29 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.27.39-1
in repository libguestfs.

commit d12f1ee99c42fe800567d82a5e99f1f31dd6760d
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Fri Sep 5 09:49:39 2014 +0100

    v2v: -i disk: Don't fail if filename has no extension.
    
    Unhelpfully, Filename.chop_extension throws an exception if the
    filename has no extension (instead of just returning the filename).
    Therefore the -i disk option would fail if you passed any filename
    that didn't have an extension.
---
 v2v/input_disk.ml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/v2v/input_disk.ml b/v2v/input_disk.ml
index aa4d409..fce11c2 100644
--- a/v2v/input_disk.ml
+++ b/v2v/input_disk.ml
@@ -39,7 +39,9 @@ class input_disk verbose input_format disk = object
      * the filename passed in.  Users can override this using the
      * `-on name' option.
      *)
-    let name = Filename.chop_extension (Filename.basename disk) in
+    let name = Filename.basename disk in
+    let name =
+      try Filename.chop_extension name with Invalid_argument _ -> name in
     if name = "" then
       error (f_"-i disk: invalid input filename (%s)") disk;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list