Changes due to different usage of temporary files.

Signed-off-by: Agata Murawska <[email protected]>
---
 lib/ovf.py |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib/ovf.py b/lib/ovf.py
index 51fc058..be5244f 100644
--- a/lib/ovf.py
+++ b/lib/ovf.py
@@ -1414,23 +1414,23 @@ class OVFExporter(Converter):
     if os.path.dirname(disk_file):
       raise errors.OpPrereqError("Path for the disk: %s contains a directory"
                                  " name" % disk_path)
-    (disk_name, _) = os.path.splitext(disk_file)
-    new_disk_name = "%s.%s" % (disk_name, self.options.disk_format)
-    new_disk_path = utils.PathJoin(self.output_dir, new_disk_name)
-    self._ConvertDisk(self.options.disk_format, disk_path, new_disk_path)
+    disk_name, _ = os.path.splitext(disk_file)
+    ext, new_disk_path = self._ConvertDisk(self.options.disk_format, disk_path)
     results["format"] = self.options.disk_format
     results["virt-size"] = self._GetDiskQemuInfo(new_disk_path,
       "virtual size: \S+ \((\d+) bytes\)")
     if compression:
-      skip_removing = disk_path == new_disk_path
-      # we do not want to delete the original disk
-      new_disk_path = self._CompressDisk(new_disk_path, "gzip", COMPRESS,
-        skip_removing=skip_removing)
-      new_disk_name = "%s%s" % (new_disk_name, COMPRESSION_EXT)
+      ext2, new_disk_path = self._CompressDisk(new_disk_path, "gzip",
+        COMPRESS)
+      disk_name, _ = os.path.splitext(disk_name)
       results["compression"] = "gzip"
-    results["real-size"] = os.path.getsize(new_disk_path)
-    results["path"] = new_disk_name
-    self.references_files.append(new_disk_path)
+      ext += ext2
+    final_disk_path = LinkFile(new_disk_path, prefix=disk_name, suffix=ext,
+      directory=self.output_dir)
+    final_disk_name = os.path.basename(final_disk_path)
+    results["real-size"] = os.path.getsize(final_disk_path)
+    results["path"] = final_disk_name
+    self.references_files.append(final_disk_path)
     return results
 
   def _ParseDisks(self):
-- 
1.7.3.1

Reply via email to