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

[Libguestfs] [PATCH] RHEV: Warn instead of die if rmtree dies during cleanup



rmtree can die instead of returning failure under some circumstances. We don't
want this to stop cleanup.
---
 lib/Sys/VirtV2V/Target/RHEV.pm |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/lib/Sys/VirtV2V/Target/RHEV.pm b/lib/Sys/VirtV2V/Target/RHEV.pm
index 295c19d..c9add0c 100644
--- a/lib/Sys/VirtV2V/Target/RHEV.pm
+++ b/lib/Sys/VirtV2V/Target/RHEV.pm
@@ -390,9 +390,18 @@ sub _cleanup
 
     return unless (defined($tmpdir));
 
-    rmtree($tmpdir) or warn(user_message(__x("Unable to remove temporary ".
-                                            "directory {dir}",
-                                            dir => $tmpdir)));
+    eval {
+        rmtree($tmpdir) or warn(user_message(__x("Unable to remove temporary ".
+                                                 "directory {dir}",
+                                                 dir => $tmpdir)));
+    };
+
+    if ($@) {
+        warn(user_message(__x("Error removing temporary directory {dir}: ".
+                              "{error}",
+                              dir => $tmpdir, error => $@)));
+    }
+
     $tmpdir = undef;
 }
 
-- 
1.7.0.1


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