diff --git a/src/sugar/bundle/bundle.py b/src/sugar/bundle/bundle.py index 0319b9ec..e9bd9f80 100644 --- a/src/sugar/bundle/bundle.py +++ b/src/sugar/bundle/bundle.py @@ -86,6 +86,9 @@ class Bundle: del file_names[0] self._zip_root_dir = file_names[0].split('/')[0] + if self._zip_root_dir.startswith('.'): + raise MalformedBundleException( + 'root directory starts with .') if self._unzipped_extension is not None: (name_, ext) = os.path.splitext(self._zip_root_dir) if ext != self._unzipped_extension: @@ -162,7 +165,8 @@ class Bundle: if os.spawnlp(os.P_WAIT, 'unzip', 'unzip', '-o', self._path, '-x', 'mimetype', '-d', install_dir): # clean up install dir after failure - shutil.rmtree(install_dir, ignore_errors=True) + shutil.rmtree(os.path.join(install_dir, self._zip_root_dir), + ignore_errors=True) # indicate failure. raise ZipExtractException