[Sugar-devel] [PATCH] sl#1876: cleanup partially extracted bundle on filesystem error

Bernie Innocenti bernie at codewiz.org
Mon Apr 26 17:31:48 EDT 2010


From: Martin Dengler <martin at martindengler.com>

This patch solves the most severe issue in #1876: filling up the
filesystem with temporary files that won't be deleted afterwards.

Before we can consider this bug completely fixed, we still need
to do something for the remaining issues:

 1) Unpacking shouldn't be attempted if there isn't a safety margin

 2) System becomes unresponsive during unpacking

 3) No progress indication for the operation, so users are tempted
    to click multiple times

 4) No error messages displayed for unpacking errors, which is a
    common Sugar nuisance.

http://bugs.sugarlabs.org/ticket/1876#comment:5 offers possible
strategies for (1) and (2).

Signed-off-by: Martin Dengler <martin at martindengler.com>
Signed-off-by: Bernie Innocenti <bernie at codewiz.org>
---
 src/sugar/bundle/bundle.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/sugar/bundle/bundle.py b/src/sugar/bundle/bundle.py
index c9763a0..a04c873 100644
--- a/src/sugar/bundle/bundle.py
+++ b/src/sugar/bundle/bundle.py
@@ -72,7 +72,12 @@ class Bundle(object):
         if os.path.isdir(self._path):
             self._zip_file = None
         else:
-            self._zip_file = zipfile.ZipFile(self._path)
+            try:
+                self._zip_file = zipfile.ZipFile(self._path)
+            except (zipfile.error, LargeZipFile), ziperror:
+                raise MalformedBundleException(
+                    "Error accessing zip file %s: %s"
+                    % (self._path, ziperror))
             self._check_zip_bundle()
 
         # manifest = self._get_file(self._infodir + '/contents')
-- 
1.7.0.1



More information about the Sugar-devel mailing list