#9925 closed defect (fixed)
[PATCH] Empty folders excluded from Zip Downloads in Browse Source
Reported by: | Owned by: | Thijs Triemstra | |
---|---|---|---|
Priority: | normal | Milestone: | 0.12.3 |
Component: | version control/browser | Version: | 0.12.1 |
Severity: | normal | Keywords: | download, browser bitesized zip |
Cc: | Thijs Triemstra | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
The "Download in other formats: Zip Archive" feature ignores folders which have no files inside. It results in missing folders in the Zip.
In our project it breaks such downloads completely because we use empty folders for example to store cache files which are not yet present in initial download but are generated later on in such folders.
Attachments (4)
Change History (18)
comment:1 by , 14 years ago
Keywords: | bitesized added |
---|---|
Milestone: | 0.12.2 → next-minor-0.12.x |
comment:2 by , 14 years ago
Cc: | added |
---|
comment:3 by , 14 years ago
Keywords: | zip added |
---|
comment:4 by , 14 years ago
Keywords: | review added |
---|---|
Milestone: | next-minor-0.12.x → 0.12.3 |
Owner: | set to |
Status: | new → assigned |
Summary: | Empty folders excluded from Zip Downloads in Browse Source → [PATCH] Empty folders excluded from Zip Downloads in Browse Source |
Attached patch creates empty directories in zip files. Also attaching the svn repo i used for testing.
by , 14 years ago
Attachment: | test-repo.dump added |
---|
follow-up: 6 comment:5 by , 14 years ago
Looks good, except for the zipfile.write(mkdtemp(), filename)
part:
- directories created like that won't get deleted automatically; you'd have to do some housekeeping (try/finally and delete it there)
- you could created only one empty directory and reuse it (and possibly only create it when actually needed?)
by , 14 years ago
Attachment: | include-folders-9925-2.patch added |
---|
follow-up: 8 comment:6 by , 14 years ago
Replying to cboos:
Looks good, except for the
zipfile.write(mkdtemp(), filename)
part:
You can also add a directory by appending a /
to the filename, and setting .external_attr
to 040755 << 16
(octal):
elif new_node.isdir: zipinfo = ZipInfo() zipinfo.filename = filename + '/' zipinfo.date_time = new_node.last_modified.utctimetuple()[:6] zipinfo.external_attr = 040755 << 16L # needed since Python 2.5 zipinfo.compress_type = compression zipfile.writestr(zipinfo, '')
comment:7 by , 14 years ago
… and this will even work with Python 2.4 and 2.5, contrary to the "temporary directory" approach.
follow-up: 9 comment:8 by , 14 years ago
Replying to rblank:
You can also add a directory by appending a
/
to the filename, and setting.external_attr
to040755 << 16
(octal):
omg, you dont want to know how many combinations I tried before finally switching from ZipFile.writestr
to ZipFile.write
. Anyway, your suggestion works perfectly (tested on py2.7.1), I'll attach an updated patch.
by , 14 years ago
Attachment: | include-folders-9925-3.patch added |
---|
comment:9 by , 14 years ago
Replying to thijstriemstra:
omg, you dont want to know how many combinations I tried before finally switching from
ZipFile.writestr
toZipFile.write
.
Heh, I cheated. I read the implementation of ZipFile.write()
in the zipfile
module for Python 2.6 :)
comment:11 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
Yes, it's fine. Putting on my todo list to apply.
comment:13 by , 14 years ago
Owner: | changed from | to
---|
comment:14 by , 14 years ago
Keywords: | review removed |
---|
PatchWelcome.