classification
Title: python -mzipfile fails to add empty folders to created zip
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.5, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Antony.Lee, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2014-08-17 17:53 by Antony.Lee, last changed 2014-10-04 11:53 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
zipfile_add_dirs.patch serhiy.storchaka, 2014-09-24 10:35 review
Messages (6)
msg225457 - (view) Author: Antony Lee (Antony.Lee) * Date: 2014-08-17 17:53
Compare

$ mkdir foo; zip -q foo{,}; unzip -l foo.zip
Archive:  foo.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2014-08-17 10:49   foo/
---------                     -------
        0                     1 file

and

$ mkdir foo; python -mzipfile -c foo{.zip,}; unzip -l foo.zip
Archive:  foo.zip
warning [foo.zip]:  zipfile is empty

A patch was posted by Ryan Wilson in related issue #22201.
msg225459 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-08-17 19:01
Directory entry should be added not only when directory is empty.

See also issue20912.
msg225530 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-08-19 12:34
I think zipfile should add an entry for directories as zip tool does. Here is a patch. In additional it fixes zipfile -c for some corner cases (when arguments end with /, . or .. component).
msg226408 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-09-05 08:26
If there are no objections I'll commit the patch soon.
msg227437 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-09-24 10:35
Hmm, looks as I forgot to attach a patch.
msg228446 - (view) Author: Roundup Robot (python-dev) Date: 2014-10-04 10:56
New changeset 911da1072099 by Serhiy Storchaka in branch '2.7':
Issue #22219: The zipfile module CLI now adds entries for directories
https://hg.python.org/cpython/rev/911da1072099

New changeset 981d18930d6d by Serhiy Storchaka in branch '3.4':
Issue #22219: The zipfile module CLI now adds entries for directories
https://hg.python.org/cpython/rev/981d18930d6d

New changeset d61d2e5a0956 by Serhiy Storchaka in branch 'default':
Issue #22219: The zipfile module CLI now adds entries for directories
https://hg.python.org/cpython/rev/d61d2e5a0956
History
Date User Action Args
2014-10-04 11:53:05serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2014-10-04 10:56:22python-devsetnosy: + python-dev
messages: + msg228446
2014-09-24 10:35:20serhiy.storchakasetfiles: + zipfile_add_dirs.patch
keywords: + patch
messages: + msg227437
2014-09-05 08:26:26serhiy.storchakasetmessages: + msg226408
2014-08-19 17:40:45serhiy.storchakalinkissue22230 superseder
2014-08-19 12:34:22serhiy.storchakasetmessages: + msg225530
stage: needs patch -> patch review
2014-08-17 19:01:56serhiy.storchakasetmessages: + msg225459
2014-08-17 18:41:08serhiy.storchakasetversions: + Python 2.7
nosy: + serhiy.storchaka

assignee: serhiy.storchaka
type: behavior
stage: needs patch
2014-08-17 17:53:45Antony.Leecreate