Throw MalformedBundleException on broken zip files
sugar.bundle.bundle.Bundle users (e.g. jarabe.model.bundleregistry.BundleRegistry._add_bundle) only expect MalformedBundleException to be thrown, not exceptions of zipfile. 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@martindengler.com> Signed-off-by: Bernie Innocenti <bernie@codewiz.org> [style fixes, adjusted description] Signed-off-by: Sascha Silbe <silbe@activitycentral.com> Reviewed-by: Aleksey Lim <alsroot@activitycentral.org>
This commit is contained in:
parent
924e2e62bf
commit
45fc0b6186
@ -71,7 +71,11 @@ class Bundle(object):
|
|||||||
self._zip_file = None
|
self._zip_file = None
|
||||||
|
|
||||||
if not os.path.isdir(self._path):
|
if not os.path.isdir(self._path):
|
||||||
self._zip_file = zipfile.ZipFile(self._path)
|
try:
|
||||||
|
self._zip_file = zipfile.ZipFile(self._path)
|
||||||
|
except zipfile.error, exception:
|
||||||
|
raise MalformedBundleException('Error accessing zip file %r: '
|
||||||
|
'%s' % (self._path, exception))
|
||||||
self._check_zip_bundle()
|
self._check_zip_bundle()
|
||||||
|
|
||||||
# manifest = self._get_file(self._infodir + '/contents')
|
# manifest = self._get_file(self._infodir + '/contents')
|
||||||
|
Loading…
Reference in New Issue
Block a user