Edgewall Software
Modify

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#9925 closed defect (fixed)

[PATCH] Empty folders excluded from Zip Downloads in Browse Source

Reported by: trustmaster@… 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)

include-folders-9925.patch (2.3 KB ) - added by Thijs Triemstra 13 years ago.
against 0.12-stable r10514
test-repo.dump (2.2 KB ) - added by Thijs Triemstra 13 years ago.
include-folders-9925-2.patch (2.9 KB ) - added by Thijs Triemstra 13 years ago.
include-folders-9925-3.patch (2.7 KB ) - added by Thijs Triemstra 13 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 by Remy Blank, 13 years ago

Keywords: bitesized added
Milestone: 0.12.2next-minor-0.12.x

comment:2 by Thijs Triemstra, 13 years ago

Cc: Thijs Triemstra added

comment:3 by Thijs Triemstra, 13 years ago

Keywords: zip added

by Thijs Triemstra, 13 years ago

Attachment: include-folders-9925.patch added

against 0.12-stable r10514

comment:4 by Thijs Triemstra, 13 years ago

Keywords: review added
Milestone: next-minor-0.12.x0.12.3
Owner: set to Thijs Triemstra
Status: newassigned
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 Thijs Triemstra, 13 years ago

Attachment: test-repo.dump added

comment:5 by Christian Boos, 13 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 Thijs Triemstra, 13 years ago

in reply to:  5 ; comment:6 by Remy Blank, 13 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 Remy Blank, 13 years ago

… and this will even work with Python 2.4 and 2.5, contrary to the "temporary directory" approach.

in reply to:  6 ; comment:8 by Thijs Triemstra, 13 years ago

Replying to rblank:

You can also add a directory by appending a / to the filename, and setting .external_attr to 040755 << 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 Thijs Triemstra, 13 years ago

in reply to:  8 comment:9 by Remy Blank, 13 years ago

Replying to thijstriemstra:

omg, you dont want to know how many combinations I tried before finally switching from ZipFile.writestr to ZipFile.write.

Heh, I cheated. I read the implementation of ZipFile.write() in the zipfile module for Python 2.6 :)

comment:10 by Thijs Triemstra, 13 years ago

Is this patch ok like this?

comment:11 by Remy Blank, 13 years ago

Owner: changed from Thijs Triemstra to Remy Blank
Status: assignednew

Yes, it's fine. Putting on my todo list to apply.

comment:12 by Remy Blank, 13 years ago

Resolution: fixed
Status: newclosed

Applied in [10665].

comment:13 by Remy Blank, 13 years ago

Owner: changed from Remy Blank to Thijs Triemstra

comment:14 by Thijs Triemstra, 13 years ago

Keywords: review removed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Thijs Triemstra.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Thijs Triemstra to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.