diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2013-09-08 08:10:20 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2013-09-08 08:10:20 (GMT) |
commit | 39f92f41f954817ce300716e8e4e6c22fd59624e (patch) | |
tree | 2b22fd8f88a68684054ca92ed7bc91ec4de069a1 | |
parent | 4c3c562d320c333d7475411990bcac53882b051e (diff) |
Process zipped directories properly
-rw-r--r-- | sugar_network/toolkit/bundle.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sugar_network/toolkit/bundle.py b/sugar_network/toolkit/bundle.py index 067bb5e..7d484ad 100644 --- a/sugar_network/toolkit/bundle.py +++ b/sugar_network/toolkit/bundle.py @@ -75,14 +75,17 @@ class Bundle(object): try: prefix = prefix.strip(os.sep) + os.sep for arcname in self.get_names(): - dst_path = arcname.strip(os.sep) + dst_path = arcname.lstrip(os.sep) if dst_path.startswith(prefix): dst_path = dst_path[len(prefix):] dst_path = join(dst_root, dst_path) - if not exists(dirname(dst_path)): - os.makedirs(dirname(dst_path)) - with file(dst_path, 'wb') as dst: - shutil.copyfileobj(self.extractfile(arcname), dst) + if dst_path.endswith(os.sep): + os.makedirs(dst_path) + else: + if not exists(dirname(dst_path)): + os.makedirs(dirname(dst_path)) + with file(dst_path, 'wb') as dst: + shutil.copyfileobj(self.extractfile(arcname), dst) except Exception: if exists(dst_root): shutil.rmtree(dst_root) |